Robert Hosking Robert Hosking - 11 months ago 59
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?


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