Robert Hosking Robert Hosking - 1 year ago 83
SQL Question

MySQL Querying Multiple Databases

I have multiple databases and I need to search for a value in a table and set it to NULL in all instances across all databases.

I know how to query individual databases after "USE 'DBName'" is called to select a particular database.

How do I loop all databases?

Answer Source

Use the SHOW DATABASES query to list all databases.

You don't need to USE the database to query its tables:

SELECT something FROM databasename.sometable