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 |
|
Incognito
Starting Member
49 Posts |
Posted - 2003-05-19 : 09:36:25
|
| Hello,Who can help me out ?The situation is like this: Two tables A and B with some records.Table A Table BXID - YID---- QID - PID17 5---- 17 517 7---- 17 717 8---- 20 120 1---- 35 220 2---- 35 335 235 3I want to show the records which not exist in Table B.For example XID 17 and YID 8 must be shown with the query. (I tried Select * From TableA, TableB Where XID = QID and YID <> PID but it did not work :((()Who can give me some tips with this ?Thnx a lot,GEdited by - Incognito on 05/19/2003 09:37:37 |
|
|
bba
Starting Member
3 Posts |
Posted - 2003-05-19 : 10:04:11
|
| Please try the following. I have also copied the results of the query. Hope this helps.create table TableA(XID int,YID int)create table TableB(QID int,PID int) insert into TableA values (17, 5)insert into TableB values (17, 5) insert into TableA values (17, 7)insert into TableB values (17, 7)insert into TableA values (17, 8)insert into TableB values (20, 1 )insert into TableA values (20, 1)insert into TableB values (35, 2 )insert into TableA values (20, 2)insert into TableB values (35, 3 )insert into TableA values (35, 2) insert into TableA values (35, 3) Select * From TableAWhere not exists(select * from TableB where (XID = QID) and (YID = PID))Result:XID YID ----------- ----------- 17 820 2 |
 |
|
|
Incognito
Starting Member
49 Posts |
Posted - 2003-05-19 : 10:13:04
|
Thnx a lot.This works perfect !   |
 |
|
|
|
|
|
|
|