Reputation: 41138
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.
How can I select the things that are inside of both using a single select statement?
Upvotes: 3
Views: 9353
Reputation: 61
SELECT
ProductosATable.*
FROM
ProductosATable
INNER JOIN ProductosBTable
ON ProductosATable.NAME = ProductosBTable.NAME
Upvotes: 1
Reputation: 26521
select a.column1, a.column2
from productosA a
join
productosB b
on
a.id = b.id
that will give you what you want
Upvotes: 3
Reputation: 15849
Try:
select * from ProductosA
intersect
select * from ProductosB
;
Upvotes: 8
Reputation: 6417
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.
Upvotes: 1
Reputation: 5769
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.
Upvotes: 0