Should I use the sql JOIN keyword for complex joins on multiple tables?

后端 未结 4 806
日久生厌
日久生厌 2021-02-03 12:42

I\'ve got the following request :

select * 
    from tbA A, tbB B, tbC C, tbD D
where 
    A.ID=B.ID and B.ID2= C.ID2 and A.ID=D.ID and C.ID3=D.ID3 and B.ID4=D.I         


        
4条回答
  •  独厮守ぢ
    2021-02-03 13:14

    SELECT * 
    FROM tba AS a
        JOIN tbb AS b ON a.id = b.id
        JOIN tbc AS c ON b.id2 = c.id2
        JOIN tbd AS d ON a.id = d.id AND c.id3 = d.id3 AND b.id4 = d.id4
    WHERE 
        a.foo = 'Foo'
    

    Though I'm having a hard time imagining any need for that. Bare to give an example, or eh more descriptive table names?

提交回复
热议问题