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)
 simple nested query

Author  Topic 

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2003-02-13 : 06:06:11
hi,
I have the following nested query:

delete from tableA where tableA.id=1 and name in (select name from tableB where tableb.id in (select tablec.id from tableC where value ='XYZ'))


but I donot want a nested query can anyone suggest a way to write this query with joins ?
any help appreciated.
Regards,
Harshal.

Expect the UnExpected

nr
SQLTeam MVY

12543 Posts

Posted - 2003-02-13 : 09:09:45
delete tableA
from tableA
join tableB
on tableA.name = tableB.name
join tableC
on tableB.id = tableC.id
and tableC.value = 'XYZ'
where tableA.id = 1

You could also put the tableC.value = 'XYZ' in the where clause if you wish.

==========================================
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

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2003-02-14 : 00:07:05
quote:

delete tableA
from tableA
join tableB
on tableA.name = tableB.name
join tableC
on tableB.id = tableC.id
and tableC.value = 'XYZ'
where tableA.id = 1

You could also put the tableC.value = 'XYZ' in the where clause if you wish.

==========================================
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.




Thanks nr.

Expect the UnExpected
Go to Top of Page
   

- Advertisement -