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
 SQL Server Development (2000)
 Delete from joined table

Author  Topic 

sky
Starting Member

10 Posts

Posted - 2002-02-11 : 05:16:10
This one sould be easy?

How do I delete the rows selected from table B in the following query.


SELECT tableA.ProductId,
tableB.fullProductId,
FROM tableA RIGHT OUTER JOIN tableB
ON tableA.ProductId = tableB.fullProductId
WHERE (tableA.ProductId IS NULL)


--------------------------------
If your swimming upstream, your going the wrong way.

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-02-11 : 06:44:27
Hi

Start with table B and left join the table A onto it.



DELETE FROM tableB
FROM tableB
LEFT JOIN tableA ON tableA.productID = tableB.fullProductID
WHERE tableA.ProductID is NULL


Note the extra FROM clause.

Hope that helps

Damian
Go to Top of Page

sky
Starting Member

10 Posts

Posted - 2002-02-11 : 11:40:21
Thanks Merkin

--------------------------------
If your swimming upstream, your going the wrong way.
Go to Top of Page
   

- Advertisement -