0

您好,感谢您的阅读。

SELECT DISTINCT (thisID and thisNAME) from table1 WHERE thisID IN
(SELECT id from table2 WHERE ... condtions)
OR 
(SELECT id from table3 WHERE ... different condtions)
OR 
(SELECT id from table99 WHERE ...even more conditions)

我需要执行一些 SELECTS 来提供这个 ID 的数量,一旦我有了这些,我只需要从表 1 中选择这个 ID 和这个名称。

我必须承认我写查询有点超出我的深度......但我确定我在正确的路线上?请问有什么帮助吗??

4

1 回答 1

3

您的 SQL 非常接近。您需要重复该IN部分并修复一些外部语法内容:

SELECT DISTINCT thisID, thisNAME
from table1
WHERE thisID IN (SELECT id from table2 WHERE ... conditions) OR 
      thisID IN (SELECT id from table3 WHERE ... different conditions) OR
      thisID IN (SELECT id from table99 WHERE ...even more conditions);
于 2015-05-18T01:21:42.927 回答