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 |
|
gadedineshreddy
Starting Member
3 Posts |
Posted - 2011-03-21 : 15:17:41
|
| how to query records in col-1 from table-1 where those records doesnot exist in col-1 in table-2 ? |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-03-21 : 15:24:54
|
| Homework?JimEveryday I learn something that somebody else already knew |
 |
|
|
gadedineshreddy
Starting Member
3 Posts |
Posted - 2011-03-21 : 15:41:57
|
| I have tried this but doesn't work. Need to change the and part in the where clause:select [USER].USER_ID, USER_NM,[USER].LAST_UPDT_BY_NM ,[USER].LAST_UPDT_TS from dbo.[USER]join USER_ROLE on [USER].USER_ID=USER_ROLE.USER_IDwhere ACTIVE_IN='1' and ( [USER].USER_ID != [USER_ROLE].USER_ID) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
latch
Yak Posting Veteran
62 Posts |
Posted - 2011-03-21 : 15:56:51
|
| Hi,Might these examples helps you. SELECT T1.col1 FROM TABLE1 T1LEFT JOIN TABLE2 T2 ON Tl.col1 = T2.col1 WHERE T1.col1 <> T2.Col1 SELECT T1.col1 FROM TABLE1 T1 WHERE T1.col1 NOT IN (SELECT T2.Col1 FROM TABLE2 T2 GROUP BY T2.Col1)SELECT T1.Col1 FROM TABLE1 T1 WHERE NOT EXISTS(SELECT T2.col1 FROM TABLE2 T2) Thanks,latch |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
gadedineshreddy
Starting Member
3 Posts |
Posted - 2011-03-21 : 16:12:01
|
| Thank You !! |
 |
|
|
|
|
|