【发布时间】:2015-05-22 14:15:02
【问题描述】:
我有一个问题
SELECT id_anything FROM table1 JOIN table2 USING (id_tables)
现在,我的情况是:
如果该连接从 table2 返回两行,我想显示 table1 中的 id_anything(仅 1 行) 如果来自 table2 的连接返回 1 行,我想显示来自 table2 的 id_anything。
Ps:表 2 中的 id_anything 返回不同的值
示例数据: 表1
id_tables | id_anything
1 | 1
表2
id_tables | id_anything
1 | 10
1 | 100
预期返回:1
【问题讨论】:
-
请添加一些示例数据(格式文本)和基于该数据的预期输出。
-
我在问题上添加了
标签: postgresql join