Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. SELECT *
  2. FROM (
  3. SELECT TABLE_NAME
  4. FROM information_schema.tables
  5. WHERE TABLE_NAME = 'MyTable1'
  6. ) AS Blah
  7.  
  8. PREPARE stmt1 from 'SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_NAME = 'MyTable1' INTO @table';
  9. EXECUTE stmt1;
  10. SET @query = CONCAT('SELECT * FROM ', @table);
  11. PREPARE stmt2 FROM @query;
  12. EXECUTE stmt2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement