Maybe I’ve been looking at this too long–but can someone please help me see why these two queries, which are supposed to return the same thing, return different numbers of rows?
select ip.*
from invoice_payment ip
inner join invoice_item II on ii.invoice_item_uuid = ip.invoice_item_uuid
inner join service_delivery sd on sd.service_delivery_uuid = ii.service_delivery_uuid
inner join #Affected on #Affected.service_delivery_uuid = sd.service_delivery_uuid
select *
from invoice_payment ip
where ip.invoice_item_uuid in (
select ii.invoice_item_uuid from invoice_item ii
where ii.service_delivery_uuid in (
select service_delivery_uuid from #Affected)
)
Thank you!
The first one returns a product:
The product is then limited by the
onconditions. But if any condition matches multiple rows, you’ll end up with more rows than there are in theIPtable.The second query returns rows in IP matching a certain condition. The second query can never return more rows than there are in IP.