title: WHERE id = (SELECT parent_id FROM sametable LIMIT 1)
body: <p>It's basically a radio button behavior but for database.</p>
  
  <p>I have table <code>galleries</code> and table <code>images</code></p>
  
  <p><code>images</code> has <code>image_id</code>, <code>gallery_id</code> and <code>featured</code> columns</p>
  
  <pre><code>1 | 55 | true
  2 | 55 | false
  3 | 55 | false
  4 | 54 | true
  </code></pre>
  
  <p>There should be only one featured image per gallery. My function should take <code>image_id</code> for the new featured image - set <code>featured</code> to true and old <code>featured</code> to false...</p>
  
  <p>How do I set the old featured image of that gallery to false and the new one to true just for that particular gallery. (I only want to provide the id of the image not the <code>gallery_id</code>.)</p>
  
  <p>I was thinking of using 2 queries: one to unset the current, one to set the new</p>
  
  <p>I couldn't get even the first one to work. Here's what I tried:</p>
  
  <pre><code>UPDATE `images` SET `featured` = 0 WHERE `featured` = 1 
  AND `page_id` = (SELECT `page_id` FROM `images` WHERE `image_id` = :image_id LIMIT 1)
  </code></pre>
  
  <p>That doesn't work for some reason. There can't be another <code>where</code> i think...</p>
  
  <p>Thanks!</p>