How do you do many to many table outer joins?

后端 未结 5 1462
陌清茗
陌清茗 2020-12-29 08:56

I have 3 tables, foo, foo2bar, and bar. foo2bar is a many to many map between foo and bar. Here are the contents.

select * from foo
+------+
| fid  |
+----         


        
5条回答
  •  春和景丽
    2020-12-29 09:09

    SELECT * FROM foo
      LEFT OUTER JOIN (foo2bar JOIN bar ON (foo2bar.bid = bar.bid AND zid = 30))
      USING (fid);
    

    Tested on MySQL 5.0.51.

    This is not a subquery, it just uses parentheses to specify the precedence of joins.

提交回复
热议问题