I have databases named like this:
database_100
database_120
database_153
database_143
...
I'll call the numbers at the end 'Databse ID' for the sake of this example.
Doing something like SHOW DATABASES LIKE "database_%
will output all the DBs and it's fine. Now I want to show databases with id = 100 or 120 or 320
this is just an example, the list of IDs itself is dynamically pulled from an array.
How can I do something like that?
EDIT:
I'm trying to use INFORMATION_SCHEMA
USE INFORMATION_SCHEMA;
SELECT `SCHEMA_NAME` from `SCHEMATA` WHERE `SCHEMA_NAME` LIKE "database_%";
but still can't figure out how to select by the dynamic IDs.
I'm thinking about something like (in pseudo code):
USE INFORMATION_SCHEMA;
SELECT `SCHEMA_NAME` from `SCHEMATA` WHERE `SCHEMA_NAME` LIKE "database_$var" WHILE $var in (121, 153, 143);
Could it be done only in SQL ?