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">
\n DELETE FROM
\n table_1, table_2
\n USING
\n table_1, table_2
\n WHERE
\n table_1.id = table_2.id
\n AND
\n table_1.id = 1
\n</cfquery>


Learn more at www.mysql.com/delete
comments powered by Disqus