Andy Jarrett // Code. Develop. Manage.

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
I’m here, learning and working away. If you liked this content and want to keep me going, consider buying me a coffee.
Your support keeps this site running and the coffee brewing! ☕️