title: MySQL IF statement to check if table is empty
body: <p>How can I create an IF statement that will insert a default row if a table is found to be empty? I'm following this logic but something is wrong.</p>
  
  <pre><code>IF ((SELECT * FROM myTable)=0)
  THEN
  INSERT INTO myTable
  (myColumn) VALUES (myValue)
  END IF;
  
  #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
  </code></pre>
  
  <p>Answer from comments (McAdam331) <a href="http://sqlfiddle.com/#!9/42229/1" rel="nofollow">http://sqlfiddle.com/#!9/42229/1</a></p>
  
  <pre><code>CREATE TABLE myTable(
    name VARCHAR(100));
  
  INSERT INTO myTable (`name`)
  SELECT 'namer'
  FROM DUAL
  WHERE NOT EXISTS (SELECT * FROM myTable);
  </code></pre>