JOIN three tables

前端 未结 2 960
半阙折子戏
半阙折子戏 2020-12-14 02:47

I am trying to retrieve two sets of information (the red and blue portions of the diagram in the one query.

I thought I could do it using the sql as stated below but

2条回答
  •  失恋的感觉
    2020-12-14 03:14

    try something like this

    SELECT A.* FROM TableA A
    LEFT OUTER JOIN TableB B ON (A.id = B.a_id)
    LEFT OUTER JOIN TableC C ON (A.id = C.a_id)
    WHERE B.a_id IS NOT NULL 
      OR c.a_id IS NOT NULL
    

提交回复
热议问题