title: Running SQL based on a query stored within a field?
body: <p>I'm trying to populate a database with certain values, based on a query stored within another table.</p>
  
  <p><strong>Table1:</strong></p>
  
  <pre><code>ID      SQL                                         Title
  1       select ID from userTable where ID = 1       Query 1
  2       select ID from userTable where ID &gt; 7       Query 2
  </code></pre>
  
  <p>I basically need to grab the 'SQL' field, and populate another table with information from the above, once the script has run it'll look something like:</p>
  
  <pre><code>ID      userID      Title
  1       1           Query 1
  2       8           Query 2
  2       9           Query 2
  2       10          Query 2
  </code></pre>
  
  <p>And so on. </p>
  
  <p>I hope that makes sense, I have absolutely no clue if it's possible - I've tried creating it as a procedure but I can't find anyway whatsoever to run the 'SQL' code from table 1 in the procedure.</p>
  
  <p>Alternatively I will do it in PHP, though it'd be preferable to get this into SQL as it's easier to automate.</p>
  
  <p>Thank you</p>