本帖最后由 lzsadam 于 2012-04-12 09:42:49 编辑

解决方案 »

  1.   

    上面格式乱掉了,这次试试
    例如:
    表A
    -----------------
    id bid name
    1  2   abc
    2      def
    3  1   ghi表B
    -----------------
    bid other
    1   aaa
    2   bbb如果A的bid关联了B的bid
    结果则为:
    -----------------
    id bid name other
    1  2   abc   aaa
    3  1   ghi   bbb以上
    A表bid为空的列就没有了现在我想要的结果则是:
    -----------------
    id bid name other
    1   2  abc  aaa
    2      def
    3   1  ghi  bbb
      

  2.   

    去搜一下join left和join right我相信能够解决你的问题
      

  3.   

    select a.id,a.bid,a.name, b.other from A a left join B b on a.bid=b.bid;
      

  4.   


    汗,我想起来了,早上脑子不清醒都忘记了
    实际上这个查询有4个表,我只改了一个left join不行就上来求助了
    所有的都改成left join正常。
    感谢,马上结帖