title: MySQL Update Query using a left join
body: <p><strong>Table Schema</strong></p>
  
  <p>Table Name: <code>file_manager_folder</code></p>
  
  <p>Rows: <code>id</code> , <code>parentId</code>, <code>name</code></p>
  
  <p>My query simulates moving a folder into another folder and accepts an array using IN(?). </p>
  
  <p>I want my update to only 'move' a folder if there is not already a folder with the same parentId and name. The kind of behaviour you would expect under any normal file system. </p>
  
  <p>So for example:</p>
  
  <pre><code>UPDATE file_manager_folder set parentId = 54 where id IN( '1','2',3') 
  </code></pre>
  
  <p>Would be a query which doesn't check anything about the parentId and name... But how can I get the left join to work. </p>
  
  <p>Here is one I tried.. which totally doesn't work. </p>
  
  <pre><code>SELECT * FROM 
      file_manager_folders as a
  LEFT JOIN file_manager_folders as b on a.id = b.id 
  WHERE b.id IS NOT NULL and a.id IN("1","2","3") and a.parentId = 54
  </code></pre>
  
  <hr>
  
  <p><code>UPDATE table1 LEFT JOIN table2 SET t1.x = t2.y ON condition WHERE conditions</code></p>