Created
June 1, 2016 15:26
-
-
Save ivanrosolen/af5f0e95ede8d7ff879bb38df10458a6 to your computer and use it in GitHub Desktop.
Use column names as select fields in another mysql query
This file contains hidden or 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
| SELECT group_concat(distinct column_name) as fields | |
| FROM information_schema.columns | |
| WHERE table_name='table_name' and column_name like 'text%' INTO @COLUMNS; | |
| SET @s = CONCAT('SELECT ',@COLUMNS,' FROM table_name limit 10'); | |
| PREPARE stmt FROM @s; | |
| EXECUTE stmt; | |
| -- DEALLOCATE PREPARE stmt; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment