Created
April 8, 2019 20:09
-
-
Save clebersonfalk/f2ca38395fb7d424d66b6e46f6afeeab to your computer and use it in GitHub Desktop.
MySQL - Select with variables, prepare statement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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