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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Find Row

Author  Topic 

lokhande.shirish
Starting Member

4 Posts

Posted - 2007-02-12 : 06:11:03
Hi,
I have following issue :


I am having two table, Table A and Table B.

Both having ID column

Table A is master table and Table B is child table.

Both table having relationship.


Table A having four records:

a
b
c
d

Table B having two records :


a
b

Now I want a query which will give me records which are not in table B i.e c and d.

I dont want IS not in format.

Can any one help me.

Regards

shirish

nr
SQLTeam MVY

12543 Posts

Posted - 2007-02-12 : 06:15:30
select *
from tbla
where id not in (select id from tblb)

select a.*
from tbla a
left join tblb b
on a.id = b.id
where b.id is null


==========================================
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.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-12 : 06:33:43
select tablea.*
from tablea left join tableb on tableb.col1 = tablea.col1
where tableb.col1 is null


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -