title: mysql use variable to store database name in sql script
body: <p>I have a sql file I will use for adding new records into a database. it involves much re-formatting data as the target is normalised to a far greater extent than the source. can I declare table names initially like</p>
  
  <pre><code>srcdb = 'dump_130113';
  targetdb = 'test';
  </code></pre>
  
  <p>then refer to them like</p>
  
  <pre><code>select * from srcdb.tablename;
  </code></pre>
  
  <p>I know about </p>
  
  <pre><code>use database_name;
  </code></pre>
  
  <p>the problem is even doing that will require switching back and forth many times.</p>