Delete from multiple tables in one query
Never had a need to do this till today, but here's how you can delete from three tables in one query. Below is the SQL i used on a MySQL DB.
<cfquery datasource="#request.dsn#" name="delQry">
DELETE FROM
table_1, table_2
USING
table_1, table_2
WHERE
table_1.id = table_2.id
AND
table_1.id = 1
</cfquery>
DELETE FROM
table_1, table_2
USING
table_1, table_2
WHERE
table_1.id = table_2.id
AND
table_1.id = 1
</cfquery>
Learn more at www.mysql.com/delete
TweetBacks
I knew there had to be a way to do it but I didn't want to sift through the mysql manual. All I kept seeing on forums was "you have to use multiple queries"..."you can't do it in one querie"....
pish posh! you can, and I did thanks to you!
keep posting all the neat0 things