Thursday, July 12, 2007

[sql] Left join to two-away table

Lesson from Yodakawa today on how to left join to a table, and then join to another 2-away table:

select A.id, B.id, B.id
from A left join (B join C on B.id = C.id) on B.id = A.id

1 comment:

  1. table "B" should be renamed "Bi" and column "id" should be renamed "idi"... it usually works better that way...

    ReplyDelete