从两个表中选择值
我有两个表,a
和 b
。两个表都包含一个 config_data
列。 a
位于一个数据库中,b
位于另一个数据库中。
我想从 a
中选择 b
中没有的值,以及 b
中但不是在a
中。
这是我当前的查询:
SELECT b.dim2
FROM sakthi_a1.`config_data` AS a
JOIN sakthi_a2.`config_data` AS b
ON a.dim2<>b.dim2
GROUP BY b.dim2
它不起作用。我需要一个查询来解决这个问题。
忘记上面的查询吧。这是错误的,我知道。
我需要根据上面给出的条件从这些表中选择一个值。是否可以?
示例数据
sakthi_a1.config_data
id dim1 dim2 config_value
1 site is_module_page 0
2 site default_html_header_tpl html_headedr.tpl
3 site facebook test
sakthi_a2.config_data
id dim1 dim2 config_value
1 site is_module_page 0
2 site default_html_header_tpl html_headedr.tpl
3 site error Invalid page
I have two tables, a
and b
. Both tables contain a config_data
column. a
is in one database and b
in another.
I want to select values from a
that are not in b
, as well as values that are in b
but not in a
.
This is my current query:
SELECT b.dim2
FROM sakthi_a1.`config_data` AS a
JOIN sakthi_a2.`config_data` AS b
ON a.dim2<>b.dim2
GROUP BY b.dim2
It's not working. I need a query to solve this problem.
Just forget about the above query. It's wrong, I know.
I need to select a value from those tables based on the conditions given above. Is it possible?
Sample data
sakthi_a1.config_data
id dim1 dim2 config_value
1 site is_module_page 0
2 site default_html_header_tpl html_headedr.tpl
3 site facebook test
sakthi_a2.config_data
id dim1 dim2 config_value
1 site is_module_page 0
2 site default_html_header_tpl html_headedr.tpl
3 site error Invalid page
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像下面的查询怎么样:
What about something like the following query:
试试这个(a中的行不在b中)
Try this (rows in a that are not in b)