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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-02-01 : 08:05:40
|
| amit writes "can we use joins to retrieve the non matching records in two tables?for e.gTable Dept has following fields1.Depid -primary key2.Depname depid depname 1 a 2 b 3 c 4 d 5 eTable Emp has following fields1.empid - Primary Key2.name 3.depid _ foreign key empid empname deptid 1 q 1 2 w 3 3 r 2can we retrieve those department id which are not in emp tableusing joins i.e i want the depid 4 and 5 which are not in emp table" |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2005-02-01 : 09:04:27
|
| [code]select depidfrom dept dleft outer join emp e on e.deptid = d.depidwhere e.empid is null[/code] |
 |
|
|
Arti
Starting Member
5 Posts |
Posted - 2005-02-01 : 13:59:52
|
| Just out left join and will get all employee without any department. |
 |
|
|
Xerxes
Aged Yak Warrior
666 Posts |
|
|
|
|
|