you can create a temporary table (as del_temp_table) by this select command:
SELECT faqcat.cat FROM faqcat LEFT JOIN article ON faqcat.cat = article.cat WHERE article.cat IS NULL; then delete them: DELETE FROM faqcat USING faqcat, del_temp_table WHERE faqcat.cat = del_temp_table.cat ; I hope it works ----- Original Message ----- From: "Darryl Hoar" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, October 07, 2003 11:10 AM Subject: Query help > I have a two tables. > One has catagories, the other has articles. > I need a query that deletes catagories only > if not articles have that catagory. > > Table faqcat(cat int not null auto_increment, name varchar(20)) > > Table article(aid in not null auto_increment, cat int, .....) > > Want to : > delete from faqcat where cat=1 (if no records in table article > have field with cat set to 1. > > how do I accomplish this with a single query ? > > thanks, > -D > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]