一次查询多个数据库 [英] Querying multiple databases at once
本文介绍了一次查询多个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在各自的数据库中都有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"
这篇关于一次查询多个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文