SQL选择两个表中的行

时间:2021-05-15 15:45:43

How can I select rows that exist is two tables. The intersection I guess? Any help?

如何选择存在的行是两个表。我觉得这个十字路口?有帮助吗?

ProductosA and ProductosB, they're both tables with the exact same number and type of columns.

ProductosA和ProductosB,它们都是具有完全相同数量和类型的列的表。

How can I select the things that are inside of both using a single select statement?

如何使用单个select语句选择两者内部的东西?

4 个解决方案

#1


3  

Try:

尝试:

select * from ProductosA
intersect
select * from ProductosB
;

#2


1  

If there is a primary/composite key join the two tables where the keys match, if there is no primary key, join them using where "and"ing match for each column.

如果主键/复合键连接键匹配的两个表,如果没有主键,则使用“和”匹配每个列的位置连接它们。

#3


0  

Simply by specifying more than one table in your FROM clause you will get rows that exist in more than one table. Whether you get their entire rows, or just part of them, depends on how many of the columns you specify in the SELECT clause.

只需在FROM子句中指定多个表,就可以获得存在于多个表中的行。无论是获取整行还是仅获取其中的一部分,都取决于您在SELECT子句中指定的列数。

#4


0  

select a.column1, a.column2
from productosA a
join
productosB b
on
a.id = b.id

that will give you what you want

那会给你你想要的

#1


3  

Try:

尝试:

select * from ProductosA
intersect
select * from ProductosB
;

#2


1  

If there is a primary/composite key join the two tables where the keys match, if there is no primary key, join them using where "and"ing match for each column.

如果主键/复合键连接键匹配的两个表,如果没有主键,则使用“和”匹配每个列的位置连接它们。

#3


0  

Simply by specifying more than one table in your FROM clause you will get rows that exist in more than one table. Whether you get their entire rows, or just part of them, depends on how many of the columns you specify in the SELECT clause.

只需在FROM子句中指定多个表,就可以获得存在于多个表中的行。无论是获取整行还是仅获取其中的一部分,都取决于您在SELECT子句中指定的列数。

#4


0  

select a.column1, a.column2
from productosA a
join
productosB b
on
a.id = b.id

that will give you what you want

那会给你你想要的