Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Join where second table has duplicate values

Status
Not open for further replies.

mrlw00r

Programmer
Aug 14, 2001
2
GB
Hi, I'm trying to join two tables, where the second table contains one column only. This second column contains duplicates of the primary key in the first table - I'm trying to get all records which are common to both, but not the duplicates... is there a simple answer and I'm just being daft?

cheers
Mike
 
select * from table1
where exists (select * from table2 where table1.key = table2.key)
 
Ahhh, sadly I'm using MySQL and exists hasn't been implemented yet!
And I've just answered my own problem... I should have used
select DISTINCT * from .............
Doh... Thanks 4 the reply though!!!

Mike
 
see MySQL forum. John Fill
1c.bmp


ivfmd@mail.md
 
If you are using a totally non ansii compliant database like SQL please have the courtesy to mention this in your post or as Johnfill said post to the appropriate forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top