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 |
|
neil_akoga
Yak Posting Veteran
56 Posts |
Posted - 2009-06-29 : 07:25:00
|
| i've got 2 tables tblUsers and tblProfilesboth can be joined via a userID columntblProfiles only has some of the users from tblUSers (e.g. 5000 users but only 3000 have profile entries in tblProfiles) How could i select the rows from tblUsers that wouldn't appear if i joined the 2 tables via userIDi know this is probably easy and i guess it involves 'not in' or something similar but it's monday and my head is pounding :(once i've done this would it be pretty straightforward to turn the select into a delete statment? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-29 : 07:38:34
|
Not tested!-- select users without profileselect tu.*from tblUSers tuleft join tblProfiles tp on tp.userID = tu.userIDwhere tp.userID IS NULL-- delete users without profiledelete tufrom tblUSers tuleft join tblProfiles tp on tp.userID = tu.userIDwhere tp.userID IS NULLFred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
|
|
|
|
|