这是我的桌子:
nID | tID | rID | code | name
------------------------------
10 | 6 | 74 | 4254 | Argos
11 | 7 | 74 | 4254 | Okrash
12 | 8 | 74 | 4254 | Pyro
13 | 8 | 0 | 4254 | Maja
14 | 9 | 74 | 4254 | Caiu
15 | 10 | 74 | 4254 | Sobre
16 | 10 | 0 | 4254 | Inye
这就是我需要的结果:
nID | name
-------------
10 | Argos
11 | Okrash
13 | Maja
14 | Caiu
16 | Inye
下面是我正在使用的 MySQL 查询。显然它不起作用(它不返回任何输出)。我还需要 nID 和 name 仅在输出中作为 2 列。想不通。
SELECT a.nID, a.name, b.nID, b.name FROM codeTable AS a
INNER JOIN codeTable AS b
ON a.rID = b.rID
WHERE a.rID='74' AND a.code='4254' AND a.tID NOT IN (10, 8)
AND b.rID='0' AND b.code='4254' AND b.tID IN (10, 8)