0

I'm trying to write a query, but wanted to approach from the different path. I want to know which are the common datas that are both appear in the other tables.

I wanted to approach it by an inner join selecting only the same columns from both tables, the following way:

select customer.customer_id, payment.customer_id
from customer
inner join payment
on customer.customer_id = payment.customer_id

which results in 19596 datas.

The other approach was to use intersect to check the common datas appearing also in both table in the following way:

select customer.customer_id from customer
intersect
select payment.customer_id from payment

which results in 599 datas.

What I don't understand is how come if I check both tables for the same information, I don't ge the same amounts of datas? What is the difference between the two functions?

jarlh
  • 42,561
  • 8
  • 45
  • 63

0 Answers0