snipt

Ctrl+h for KB shortcuts

Text only

Delete from multiple tables using joins MySQL

1
2
3
4
DELETE table1, table2, table3 FROM table1
LEFT JOIN table2 USING(field)
LEFT JOIN table3 USING(field)
WHERE table1.field = 'value'
https://snipt.net/embed/d14c936ec5483be1ccc8f7451503f77c/
/raw/d14c936ec5483be1ccc8f7451503f77c/
d14c936ec5483be1ccc8f7451503f77c
text
Text only
4
2019-08-17T22:33:25
True
False
False
Feb 12, 2013 at 09:29 AM
/api/public/snipt/55627/
delete-from-multiple-tables-using-joins-mysql
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>DELETE table1, table2, table3 FROM table1 </span><span id="L-2"><a name="L-2"></a>LEFT JOIN table2 USING(field) </span><span id="L-3"><a name="L-3"></a>LEFT JOIN table3 USING(field) </span><span id="L-4"><a name="L-4"></a>WHERE table1.field = &#39;value&#39; </span></pre></div> </td></tr></table>