MariaDB: Issues with SQL delete using exist clause
<p>I ran this select in MariaDB and it worked as expected, it was just a select with <code>exists</code>: </p>
<pre class="brush:php;toolbar:false;">select * from pred_loan_defaults d
where exists (select 1 from pred_loan_defaults d2
where d.exec_id = d2.exec_id and d.loan_identifier = d2.loan_identifier
and d2.default_status = 1 and d.prediction_date > d2.prediction_date)
order by loan_identifier, prediction_date</pre>
<p>Now, I'm trying to delete the selected rows, so I adapted the statement: </p>
<pre class="brush:php;toolbar:false;">delete from pred_loan_defaults d
where exists (select * from pred_loan_defaults d2
where d.exec_id = d2.exec_id and d.loan_identifier = d2.loan_identifier
and d2.default_status = 1 and d.prediction_date > d2.prediction_date);</pre>
<p>But I get an error: </p>
<blockquote>
<p>SQL Error [1064] [42000]: (conn=6) There is an error in your SQL
Syntax; check the manual for your MariaDB server
Version using correct syntax near 'd</p>
</blockquote>
<p><code>delete</code> What's wrong with the statement? </p>