title: Usage of MySQL's "IF EXISTS"
body: <p>Here are two statements that I'd like to work, but which return error messages:</p>
  
  <pre><code>IF EXISTS (SELECT * FROM gdata_calendars WHERE `group` =  ? AND id = ?) SELECT 1 ELSE SELECT 0
  </code></pre>
  
  <p>and</p>
  
  <pre><code>IF ((SELECT COUNT(*) FROM gdata_calendars WHERE `group` =  ? AND id = ?) &gt; 0)  SELECT 1 ELSE SELECT 0;
  </code></pre>
  
  <p>The question marks are there because I use parametrized, prepared, statements with PHP's PDO. However, I have also tried executing this with data manually, and it really does not work.</p>
  
  <p>While I'd like to know why each of them doesn't work, I would prefer to use the first query if it can be made to work.</p>