Skip to content

Instantly share code, notes, and snippets.

@clebersonfalk
Created April 8, 2019 20:09
Show Gist options
  • Save clebersonfalk/f2ca38395fb7d424d66b6e46f6afeeab to your computer and use it in GitHub Desktop.
Save clebersonfalk/f2ca38395fb7d424d66b6e46f6afeeab to your computer and use it in GitHub Desktop.
MySQL - Select with variables, prepare statement
SET @id_escritorio := '18';
SET @query1 = CONCAT('SELECT * FROM escritorio_', @id_escritorio,'.banco ORDER BY id_banco DESC');
PREPARE stmt1 FROM @query1;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment