Home  >  Q&A  >  body text

Is there anything wrong with this statement? It gives syntax error: delete from table1 t1 left join table2 t2 on t1. Id=t2.id, where t2.id is empty

<p>Is there anything wrong with this statement? Syntax error occurred in mysql</p> <pre class="brush:php;toolbar:false;">delete from table1 t1 left join table2 t2 on t1. Id=t2.id where t2.id is null</pre> <p>Please give us your suggestions</p>
P粉148434742P粉148434742381 days ago519

reply all(1)I'll reply

  • P粉798343415

    P粉7983434152023-09-06 15:24:35

    When joining, you need to specify which table you want to delete from

    delete t1
    from table1 t1 
    left join table2 t2 on t1.Id = t2.id 
    where t2.id is null

    reply
    0
  • Cancelreply