Miles Thompson wrote:
That looks a lot more professional - thanks.
No problem! test it out first, though! ;)
Where can I get information on writing better SQL?
There's lots of good books on it. Joe Celko's SQL for Smarties books
are great for that stuff. (Also, shameless plug: my own book "Pro
MySQL" (Apress, 2005) has a couple chapters on effective SQL coding.. :)
Cheers,
Jay
Regards - Miles Thompson
From: Jay Pipes <[EMAIL PROTECTED]>
DELETE bm_KW FROM bm_KW
INNER JOIN (
SELECT kw2.KeywordID
FROM bmjn_KW kw1
INNER JOIN bmjn_KW kw2
ON kw1.KeywordID = kw2.KeywordID
AND kw2.ItemID != '1016'
WHERE kw1.ItemID = '1016'
) AS keywords
ON bm_KW.KeywordID = keywords.KeywordID;
Miles Thompson wrote:
This query works but is there any way of making it more elegant or
speeding it up?
DELETE from bm_KW USING bm_KW, bmjn_KW
WHERE
bm_KW.KeywordID IN
(SELECT bmjn_KW.KeywordID FROM bmjn_KW
WHERE bmjn_KW.ItemID = '1016' ) AND
bm_KW.KeywordID NOT IN
(SELECT bmjn_KW.KeywordID FROM bmjn_KW
WHERE bmjn_KW.ItemID != '1016');
<snip>
_________________________________________________________________
Buy what you want when you want it on Sympatico / MSN Shopping
http://shopping.sympatico.msn.ca/content/shp/?ctId=2,ptnrid=176,ptnrdata=081805
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]