return 1 row of data

J

John B

how do you return only 1 row of data on each of the duplicates?

e.g.

select tab1.col1, tab2.col2, tab2.col3
from tab1 left join tab2 on tab1.col1 tab2.col1

this query produces mutiple rows as tab2.col1 is not unique.

I just want the "first duplicate" instead of all the duplicates.

Thanks,

JB
 
J

John Spencer

Try using the DISTINCT keyword

SELECT DISTINCT tab1.col1, tab2.col2, tab2.col3
FROM tab1 left join tab2 on tab1.col1 = tab2.col1

This query will NOT be updatable
 
J

John B

Thanks mate!


John Spencer said:
Try using the DISTINCT keyword

SELECT DISTINCT tab1.col1, tab2.col2, tab2.col3
FROM tab1 left join tab2 on tab1.col1 = tab2.col1

This query will NOT be updatable
 
Top