I have a sql Query Like this
Select a.column1,b.column2,c.column3
from table1 a,table2 b, table3 c
where a.customerName = 'Michael'
and a.id= b.id
and a.id = c.id
and b.id = c.id
My problem is table 1 and table 2 have only one row satisfying this condition always so there is no issues but table3 column 3 contains two rows so duplication fo rows happen just to display the two values of table3. How can I return only one row of c.column3 from table3 irrespective of how many rows it has?
I tried using
Select a.column1,b.column2,c.(TOP 1 column3)
from table1 a,table2 b, table3 c
where a.customerName = 'Michael'
and a.id= b.id
and a.id = c.id
and b.id = c.id
but still it did not work. Is there a way to achieve this? I am using SQL database.
Example :
select a.Full_Name FROM table1 a WHERE a.ID LIKE '%1002%'
this gives
Full_Name Arun TestName
But when I do
select a.FullName,b.work FROM table1 a, table2 b WHERE a.ID = b.id AND a.ID LIKE '%1002%'
This gives since work column for the ID 1002 has two rows (one row containing 2 and another row containing 1)
Full_Name work Arun 2 Arun 2 TestName 1 TestName 1
My expected output is instead of returning both the rows I would like it(work column) to return only one row. how is this achieved?