title: How to check if MySQL query is valid without executing it?
body: <p>I'm making a simple tool that will get a string of MySQL commands and run it (on several DB servers sequentially). I trust the users to be sensible, but mistakes happen, and I'm looking for a way to prevent basic typos:</p>
  
  <p>Is there a way to validate, at runtime, (relatively simple) MySQL queries to see if they're syntactically correct?</p>
  
  <p>I'm not looking for semantic correctness, e.g. table names or join applicability; just something like a spellcheck for SQL queries.</p>
  
  <p>In other words, </p>
  
  <pre><code>SELECT * FROM x;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>INSERT INTO x SET id=1,bar="foo";
  </code></pre>
  
  <p>would be marked valid, whereas any of those would not:</p>
  
  <pre><code>SELECT FROM x;
  SECLET * RFOM x;
  ISNETR INTO x SET id=1;
  HJBGYGCRYTCY;
  </code></pre>
  
  <p>For <code>SELECT</code>s, I could bend <code>EXPLAIN</code> to my needs - run <code>EXPLAIN SELECT (...)</code> and watch for errors, but is there a way to check for other commands as well? </p>