yosig81 yosig81 - 2 months ago 10
MySQL Question

"Show databases" with condition

i would like to query a MySql Database to show me all the existing databases based on provided condition (condition applied on the database name).
now since my condition is complex, the simple "LIKE" condition is not enough, and i need to use the regular WHERE clause.

can anyone provide a sample of how to do that?

Answer
USE INFORMATION_SCHEMA;
SELECT `SCHEMA_NAME` from `SCHEMATA` WHERE `SCHEMA_NAME` LIKE "%whatever%";

Read more in the docs.

Comments