我目前想将两个 SQL 查询合二为一。这有点类似于SQL:获取查询的结果并使用它另一个 - combine。假设有两个查询:
SQL 语句
1.) SELECT *
FROM (SELECT B.example1
FROM EXAMPLE1A A
INNER JOIN EXAMPLE1B B ON A.ID = B.ID
WHERE A.ABC ='ABC'
ORDER BY A.ORDER_BY ) as colstate
2.) SELECT colstate
FROM EXAMPLE_TABLE
WHERE EFG LIKE '%'
AND BGTHAN >= '1'
AND SMTHAN <= '100'
ORDER BY ORDER_BY ASC
我想使用查询 1.) 中的结果作为查询 2.) 中的 colstate(列语句)。但:
我试过的是:
SELECT (SELECT B.example1
FROM EXAMPLE1A A
INNER JOIN EXAMPLE1B B
ON A.ID = B.ID
WHERE A.ABC ='ABC'
ORDER BY A.ORDER_BY )
FROM EXAMPLE_TABLE
WHERE EFG LIKE '%'
AND BGTHAN >= '1'
AND SMTHAN <= '100'
ORDER BY ORDER_BY ASC
结果是Error: Scalar subquery is only allowed to return a single row,我应该如何将“=”替换为“IN”?还是我的说法完全错误?