title: SQL - for each (if... then... else...)
body: <p>I'm trying to test a sql database that I created. To do so, I've got 2 tables: items and brands. Items store different fields including the name of a brand, and brands store other fields including a name. I would like to check that for each brand in items, there is a corresponding name in brands table. How would I do that ? I thought of something along the lines of:</p>
  
  <pre><code>"for each row in items"
  if (count(select * from items join brands on items.brand = brands.name) == 0, select items.name, '');
  </code></pre>
  
  <p>But then I don't know how to include the for statement in it... Any ideas?</p>