一次查询多个数据库
我有 WordPress 实例,每个实例都在自己的数据库中.对于更新,我需要查询所有活动插件,这些插件存储在表wp_options"中并可通过
I have WordPress instances with each in its own database. For an update I need to query all active plugins, that are stored in a table 'wp_options' and accessible via
WHERE option_name='active_plugins'
如何访问所有活动插件设置(分布在多个数据库中)并将它们输出到一个 SQL 结果中?我知道 database.tablename
语法,但如何使用上述 Where
语句从那里继续?
How can I access all active plugin settings (spread over multiple databases) and output them in one single SQL result? I know the database.tablename
syntax, but how do I go on from there with the above Where
statement?
单个数据库中的请求如下所示:
A request in a single database would look like this:
SELECT option_value
FROM `database`.`wp_options`
WHERE option_name="active_plugins"
推荐答案
SELECT option_value
FROM `database1`.`wp_options`
WHERE option_name="active_plugins"
UNION
SELECT option_value
FROM `database2`.`wp_options`
WHERE option_name="active_plugins"
相关文章