sql - What is the difference between these two queries(Using IN and JOIN)? -
i have find whatever matching records(npi) there in both. tried both below queries. both giving different results in count (say 12000 , 200000 respectively). between:
select * emblem_attested npinumber in (select npinumber empire_attested)
and
select * empire_attested emp join emblem_attested emb on emp.npinumber = emb.npinumber
i don't know 1 correct.
the in
clause give rows in emblem_attested
have npinumber
in empire_attested
. if there records in emblem_attested
same npinumber
not affect result.
for example, if emblem_attested
has npinumber
of 1
, empire_arrested
table has multiple records npinumber
of 1
. 1 record returned npinumber
of 1
.
the join
give more record if there multiple records in emblem_attested
same npinumber
. if there duplicate npinumber in emblem_attested
more records in results join
. seeing.
with join
, if emblem_attested
has npinumber
of 1
, empire_arrested
table has multiple records npinumber
of 1
. multiple records returned join return record each record in empire_arrested
npinumber
of 1
.
Comments
Post a Comment