ORACLE Commonly used functions for data comparison between two tables or two result sets

Suppose there are two tables A and B, each with only one field PHONE

1、MINUS

SELECT PHONE FROM A MINUS SELECT PHONE FROM B; Equivalent to the result set obtained by subtracting the result B from the result set A. The same effect can also be achieved with SELECT PHONE FROM A WHERE NOT EXISTS(SELECT 1 FROM B WHERE A.PHOEN=B.PHONE).

 

2、INTERSECT

SELECT PHONE FROM A INTERSECT SELECT PHONE FROM B; is equivalent to finding the intersection of result set A and result set B.

 

3、UNION

SELECT PHONE FROM A UNION SELECT PHONE FROM B; is equivalent to finding the combination of result set A and result set B, and deduplication.

 

4. UNION ALL
SELECT PHONE FROM A UNION ALL SELECT PHONE FROM B; is equivalent to seeking the combination of result set A and result set B, without deduplication.

 

Reprinted: https://my.oschina.net/u/2003855/blog/307369

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326286403&siteId=291194637