我有一个查询:
driver.wait_until_page_loads()
返回此结果集:
SELECT t.USER_ID, c.CODE
FROM TRANSACTIONS t
INNER JOIN USER u ON t.USER_ID = u.USER_ID
INNER JOIN COMPANY c ON c.CODE = u.CODE
然后我有一个表USER ID CODE
-----------------
01 100
02 100
03 100
03 120
(例如),该表列出了与代码的所有交互:
INTERACTIONS
CODE INTERACTION WORKED_YN
-----------------------------------
100 Sample 01 Y
100 Sample 02 Y
120 Sample 03 N
120 Sample 04 N
etc.
列值应始终具有相同的结果(即100始终为Y,120始终为N)。
如何在不进行任何交互的情况下联接表CODE
,以便获得以下输出:
INTERACTIONS
答案 0 :(得分:1)
由于在结果集中不需要INTERACTIONS.INTERACTION
列,因此您可以对INTERACTIONS
表进行子查询,以获得省略该列的独特记录:
SELECT t.USER_ID, c.CODE
FROM (SELECT DISTINCT CODE, WORKED_YN, USER_ID FROM TRANSACTIONS) t
INNER JOIN USER u ON t.USER_ID = u.USER_ID
INNER JOIN COMPANY c ON c.CODE = u.CODE