title: how to update table with subquery in where clause
body: <p>i have a main table <code>categories</code> like this</p>
  
  <pre><code>categories_id | categories_status | parent_id
       1                  1               0
       2                  1               0
       3                  1               1
       4                  1               2
       5                  1               1
       6                  1               2
  </code></pre>
  
  <p>and a reference table <code>products_to_categories</code></p>
  
  <pre><code>categories_id | products_id
        3             778
        3             998
        5             666
        5             744
  </code></pre>
  
  <p>I select all the categories with no child-category:</p>
  
  <pre><code>SELECT * FROM categories
  WHERE categories_id not in ( SELECT parent_id FROM categories )
  # gets entries with id 3, 4, 5, 6
  </code></pre>
  
  <p>and no products in reference table:</p>
  
  <pre><code>AND categories_id NOT IN ( SELECT categories_id FROM products_to_categories )
  # gets entries with id 4, 6
  </code></pre>
  
  <p>Now i would like to update the categories_status for this result but it don't work just changing SELECT to UPDATE:</p>
  
  <pre><code>UPDATE categories
  SET categories_status = 0
  WHERE categories_id not in ( SELECT parent_id FROM categories )
  AND categories_id NOT IN ( SELECT categories_id FROM products_to_categories )
  </code></pre>
  
  <p>There a few similar questions, but i can't figure out how to change my example...</p>
  
  <p>Thanks &amp; best regards,</p>
  
  <p>Alex</p>