Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql Oracle查询以获取第一个表的不同值_Sql_Oracle - Fatal编程技术网

Sql Oracle查询以获取第一个表的不同值

Sql Oracle查询以获取第一个表的不同值,sql,oracle,Sql,Oracle,我有一个如下的场景,我想知道oracle查询以获得第一个表USERcolumn的不同值 EXPECTED RESULT ID | USER 11 | user3 12 | user4 CURRENT TABLES TABLE A TABLE B ID | USER ID | USER 1

我有一个如下的场景,我想知道oracle查询以获得第一个表
USER
column的不同值

EXPECTED RESULT

ID   |  USER                       
11   |  user3                     
12   |  user4 




CURRENT TABLES

TABLE A                TABLE B  

ID   |  USER           ID   |  USER            
11   |  user1          11   |  user1           
11   |  user2          11   |  user2          
11   |  user3          12   |  user5
12   |  user4
12   |  user5  

一个简单的方法是使用
减号

select id, user
from a
minus
select id, user
from b;

一个简单的方法是使用
减号

select id, user
from a
minus
select id, user
from b;

另一种方法是:

select * from tableA where user not in (select distinct(user) from tableB)

另一种方法是:

select * from tableA where user not in (select distinct(user) from tableB)