title: MySql - Create Table If Not Exists Else Truncate?
body: <p><strong>Here is the updated question:</strong></p>
  
  <p>the current query is doing something like:<br></p>
  
  <pre><code>$sql1 = "TRUNCATE TABLE fubar";
  $sql2 = "CREATE TEMPORARY TABLE IF NOT EXISTS fubar SELECT id, name FROM barfu";
  </code></pre>
  
  <p>The first time the method containing this is run, it generates an error message on the truncate since the table doesn't exist yet.</p>
  
  <p>Is my only option to do the <code>CREATE TABLE</code>, run the <code>TRUNCATE TABLE</code>, and then fill the table? (3 separate queries)</p>
  
  <p><strong>original question was:</strong></p>
  
  <p>
  I've been having a hard time trying to figure out if the following is possible in MySql without having to write block sql:</p>
  
  <pre><code>CREATE TABLE fubar IF NOT EXISTS ELSE TRUNCATE TABLE fubar
  </code></pre>
  
  <p>If I run truncate separately before the create table, and the table doesn't exist, then I get an error message.  I'm trying to eliminate that error message without having to add any more queries.</p>
  
  <p>This code will be executed using PHP.</p>