title: 2 temp table mysql using union
body: <p>I have made 2 temporary tables and tried to do union commands on these 2 tables, but I have found an error message:
  error code: 1137
  Can't reopen table: 'stock'
  the following is the query that I have made:</p>
  
  <pre><code>DROP TABLE IF EXISTS stok;
  DROP TABLE IF EXISTS bdp;
  CREATE TEMPORARY TABLE stok AS(SELECT * from productA);
  
  CREATE TEMPORARY TABLE bdp AS(SELECT * from quantity);
  
  SELECT AllSubs.kode, stok.stok,bdp.qty FROM
  (SELECT kode FROM stok
  UNION
  SELECT kode FROM bdp) AS AllSubs
  LEFT JOIN stok ON stok.kode = AllSubs.kode
  LEFT JOIN bdp ON bdp.kode = AllSubs.kode
  GROUP BY AllSubs.kode
  </code></pre>
  
  <p>as I mentioned above, this query appears an error message: 
  Error Code: 1137
  Can't reopen table: 'stok'</p>
  
  <p>please your help, thanks</p>