Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
SwanAL
Starting Member
5 Posts |
Posted - 2013-09-06 : 10:42:50
|
Hi all,I have a question:table 1 is:number | name1 | a2 | b3 | ctable 2 is:number | code1 | abc1 | def3 | zuias you see, in table 2 "number" is not unique and can have double entrysnow I want to join these tables:1.) i dont want any double "number"2.) I only want entrys which are mentione in table 2so as the result I want:number | name1 | a3 | cHow has the join to look like?Or if there is no working join, how could I delete all entrys in table 2 where there are several "number" (but one entry)Hope everything is clear.Thanks for your help and kind regards,SwanAL |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-09-06 : 11:11:46
|
You can write the query a few different ways - for example:SELECT number, nameFROM Table1 a WHERE EXISTS (SELECT * FROM Table2 b WHERE b.number = a.number); |
 |
|
|
|
|