Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

query returning duplicates

$
0
0
I have written this query which searches the table and return all owners whose surnames are like 'BLACK'. It runs fine but it is returning duplicate rows. I think this may be a problem with my joins. Does anyone have any suggestions?

Code:

SELECT p.person_id FROM person p, owner o, buliding b, person_status ps
WHERE o.owner_id = p.owner_id AND b.building_id = h.building_id
AND p.person_id=ps.status_id AND ps.status_type='H'
and  o.surname LIKE '%BLACK';


Viewing all articles
Browse latest Browse all 13329

Trending Articles