What is the standard SQL Query to retrieve the intersection of tables?

前端 未结 9 742
谎友^
谎友^ 2021-02-02 03:57

Selecting the union:

select * from table1 
union 
select * from table1_backup 

What is the query to select the intersection?

9条回答
  •  你的背包
    2021-02-02 04:45

    An intersect on two identical tables a and b can be done in this manner:

    SELECT a.id, a.name
    FROM a INNER JOIN b
    USING (id, name)
    

提交回复
热议问题