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 |
|
azvelos
Starting Member
1 Post |
Posted - 2009-06-18 : 08:02:06
|
| HiI have two tableshow do I retrieve records which exists in one table but not in the other (accordding to a common field that have a different name but same type)? |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2009-06-18 : 08:10:22
|
| select t1.*from tbl1 t1left join tbl2.t2on t1.fld1 = t2.fld2where t2.fld2 is nullselect *from tbl1where fld1 not in (select distinct fld2 from tbl2)select *from tbl1 t1where not exists (select * from tbl2 t2 where t2.fld2 = t1.fld1)lots of other ways==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-06-18 : 08:28:42
|
| In 2005 , you can useselect * from tbl1 exceptselect * from tbl2MadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-06-18 : 08:30:58
|
| and Nigel's first query should beselect t1.*from tbl1 t1left join tbl2 t2on t1.fld1 = t2.fld2where t2.fld2 is nullMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|