We have tables A, B, and C, and we would like to find A related to a particular C.
SELECT*
FROM A A
INNER JOIN B
ON b.id = a.b_id
LEFT JOIN CC
ON c.b_id=b.id AND c.type='hogehoge'
WHERE c.id IS NULL
At this time, other types other than c.type='hogehoge'
are also extracted.
If you only want to extract records with type='hogehoge'
, use c.type='hogehoge'
as an extraction condition, not a merge condition.
SELECT*
FROM A A
INNER JOIN B
ON b.id = a.b_id
LEFT JOIN CC
ON c.b_id=b.id
WHERE c.type = 'hogehoge'
© 2024 OneMinuteCode. All rights reserved.