ORACLE SQL查询,从其他表中的行字符串匹配的行返回值
我正在努力让这项工作,它应该是简单的,但我有麻烦钉下来。我只需要返回num的值,其中字符串在同一个表和另一个表中匹配 表1ORACLE SQL查询,从其他表中的行字符串匹配的行返回值,sql,oracle,subquery,Sql,Oracle,Subquery,我正在努力让这项工作,它应该是简单的,但我有麻烦钉下来。我只需要返回num的值,其中字符串在同一个表和另一个表中匹配 表1 string num ------- ----- xyzxy 100 表2 string othernum -------- -------- xyzxy 200 SELECT num FROM table1 WHERE (SELECT string FROM table1 = SELECT string FROM tab
string num
------- -----
xyzxy 100
表2
string othernum
-------- --------
xyzxy 200
SELECT num FROM table1 WHERE (SELECT string FROM table1 = SELECT string FROM table2)
使用exists()
使用exists()
在(?)中使用:
这应该有效。在(?)中使用:
这应该行得通。您也可以使用以下查询:
SELECT t1.num FROM table1 t1 join table2 t2
WHERE t1. string = t2.string;
您还可以使用以下查询:
SELECT t1.num FROM table1 t1 join table2 t2
WHERE t1. string = t2.string;
添加更多示例表数据并指定预期结果。添加更多示例表数据并指定预期结果。
SELECT t1.num FROM table1 t1 join table2 t2
WHERE t1. string = t2.string;