MYSQL Select tableX from all databases
Let's say I have 50 databases that all have same schema and all have table 'plays'.
Is there any possible way to SELECT all the data from table 'plays' from all the databases at once ?
Is there any way to do this if I dont know how many databases I have ?
Currently I would do this :
(SELECT * FROM db1.plays WHERE开发者_如何学Go condition)
UNION
(SELECT * FROM db2.plays WHERE condition)
UNION...
(SELECT * FROM db50.plays WHERE condition)
Is there any way to write less code for this ?
Regards
I'm not sure, but to shorten your code, you could do
Select * FROM db1.plays, db2.plays, ...., db3.plays WHERE <condition>
Another thing that comes to mind is using the table INFORMATION_SCHEMA. Maybe someone else has a better idea.
精彩评论