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 |
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2002-05-26 : 23:31:33
|
| I am creating a SQL statement as such:SELECT userID FROM TBLUSERDETAILSHow can I only bring back the records if the userID in TBLUSERDETAILS is also found in TBLPHOTO.??Im not sure where to go with this, I'm thinking something along the lines of a join?Thanks alot, mike |
|
|
jbkayne
Posting Yak Master
100 Posts |
Posted - 2002-05-26 : 23:37:18
|
| SELECT TBLUSERDETAILS.userIDFROM TBLUSERDETAILSinner join TBLPHOTOon TBLUSERDETAILS.userId = TBLPHOTO.userId or SELECT userIDFROM TBLUSERDETAILSWHERE EXISTS (select * from TBLPHOTO where userId = TBLUSERDETAILS.userID)Edited by - jbkayne on 05/26/2002 23:39:29 |
 |
|
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2002-05-26 : 23:48:41
|
| Is one of those particularly faster than the other?thanks alot,mike |
 |
|
|
dataphile
Yak Posting Veteran
71 Posts |
Posted - 2002-05-28 : 07:51:58
|
| The first one will be faster.The second one could give you inconsistent results if there are no referential constraints defined between the two tables. |
 |
|
|
|
|
|