View Single Post

   
  #4 (permalink)  
Old 02-28-2008, 07:52 AM
Bill Karwin
 
Posts: n/a
Default Re: DELETE where NOT EXISTS

Paul Lautman wrote:
> I can successfully perform the query


Ah, mea culpa, I posted my previous response hastily; obviously you are
using MySQL 4.1 if the subquery in the SELECT works.

I'd suggest this rewrite:

DELETE FROM `mos_availability` a WHERE a.user NOT IN (
SELECT b.id
FROM mos_users b

Or use MySQL's multi-table DELETE syntax:

DELETE a
FROM `mos_availability` AS a
LEFT JOIN `mos_users` AS b ON a.user = b.id
WHERE b.id IS NULL

Regards,
Bill K.
Reply With Quote