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');
Its purpose is to delete only the keywords which are unique to the item
being deleted, "1016" in this case.
The bm_KW table stores the keywords and consists of two columns: KeywordID
and Keyword. KeywordID is an auto-incrementing primary key.
The bmjn_KW table stores only pointers to keywords and items and consists of
two columns: ItemID - a foreign key pointing to the id of a given item - and
KeywordID a foreign key pointing to the KeywordID in the bm_KW table.
When an item is added the bm_KW table is searched to determine if any of the
keywords used to describe it have been used before. If so a record is added
to bmjn_KW referencing the item and the KeywordID in bm_KW.
If the keyword has not been used it is added to bm_KW and then referenced as
described above.
Any thoughts or opinions?
Regards - Miles Thompson
_________________________________________________________________
Win a trip for four to a concert anywhere in the world!
http://www.mobilelivetour.ca/
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]