title: MySql create variable from sql select
body: <p>Is there way to create variable from select ?</p>
  
  <pre><code>set @MY_ID = 'SELECT ID FROM TMS.MY_TABLE WHERE MY_TABLE.UNIQ_COLUMN= 2134';
  </code></pre>
  
  <p>Code above works but it just saves string:</p>
  
  <p><code>SELECT @MY_ID;</code> returns </p>
  
  <blockquote>
    <p>SELECT ID FROM TMS.MY_TABLE WHERE MY_TABLE.UNIQ_COLUMN= 2134'</p>
  </blockquote>
  
  <p>I have to know this id to use it as foreign key to insert into another tables</p>