我在sql developer(TABLE,TABLE1,TABLE2和TABLE3)中有4个表,我想知道这4个表中是否存在某个值(例如TIE = 100)。
4个表与“TIE”列具有相同的结构。
我想知道TIE值在哪个表中等于100。
我已经在sql中写了这个,但它不起作用:
SELECT TIE ,
instr
FROM
(SELECT TABLE1.TIE,
'terre' instr
FROM TABLE,
TABLE1
)
UNION
(SELECT TABLE2.TIE,
'air' instr
FROM TABLE,
TABLE2
)
UNION
(SELECT TABLE3.TIE,
'mer' instr
FROM TABLE,
TABLE3
)
WHERE TIE = '100';
任何帮助将不胜感激......
答案 0 :(得分:1)
以下查询可能会提供所需的结果: -
select TIE,instr
from
(
SELECT TIE,'terre' instr
FROM TABLE
UNION
SELECT TIE,'terre' instr
FROM TABLE1
UNION
SELECT TIE, 'air' instr
FROM TABLE2
UNION
SELECT TIE,'mer' instr
FROM TABLE3
) A where TIE=100
答案 1 :(得分:0)
尝试:
SELECT TIE , 'terre' instr
FROM TABLE
WHERE TIE = '100'
UNION
SELECT TIE , 'terre' instr
FROM TABLE1
WHERE TIE = '100'
UNION
SELECT TIE, 'air' instr
FROM TABLE2
WHERE TIE = '100';
UNION
SELECT TIE, 'mer' instr
FROM TABLE3
WHERE TIE = '100';