title: Delete rows from a left join
body: <p>I want to join two tables and delete from them. </p>
  
  <p>table1:</p>
  
  <pre><code>|ID| DATA|
  </code></pre>
  
  <p>table2:</p>
  
  <pre><code>|ID | ID_TAB1|
  </code></pre>
  
  <p>The query looks like this:</p>
  
  <pre><code>delete from table2 
  using table2 as t2 left join table1 as t1 
  on t2.ID_TAB1=t1.ID 
  where t1.DATA='xxx';
  </code></pre>
  
  <p>The problem is that there is a third table:</p>
  
  <p>table3:</p>
  
  <pre><code>|ID|ID_TAB2|
  </code></pre>
  
  <p>When I run my statement it fails saying </p>
  
  <blockquote>
    <p>Update or deleting on table table2 violates foreign key contraint on table table3</p>
  </blockquote>
  
  <p>I'm sure there are no data in the table3 connected to rows with <code>t1.DATA='xxx'</code> so why is there this error? Isn't my query correct?</p>