右外连接没有得到相同的结果不知道为什么(= *)

时间:2014-09-01 06:37:50

标签: sql sql-server database join helper

嗨,所有新的数据库外连接和内部连接都修改为

下面的代码
FROM leaf_star_stem_bud, leaf_star_item, cosmic_tank 
WHERE leaf_star_stem_bud.power_company_key  =  '6aa5' 
      And leaf_star_item.parent_key = 'eaab1' 
      And cosmic_tank.master_key = leaf_star_item.cost_code_key 
      And leaf_star_stem_bud.parent_key  =*  leaf_star_item.master_key  

FROM leaf_star_stem_bud 
    RIGHT OUTER JOIN leaf_star_item ON 
     leaf_star_stem_bud.parent_key = leaf_star_item.master_key , cosmic_tank 
WHERE leaf_star_stem_bud.power_company_key  =  '6aa5' 
       And leaf_star_item.parent_key = 'eaab1'
       And cosmic_tank.master_key = leaf_star_item.cost_code_key

但查询得不到同样的结果,请你帮帮我

1 个答案:

答案 0 :(得分:1)

INNER JOIN 加入

  • 向我提供所有 leaf_star_stem_bud ,其中包含 leaf_star_item

RIGHT JOIN RIGHT OUTER JOIN

  • 向我提供所有 leaf_star_stem_bud ,其中包含 leaf_star_item
  • 如果还有更多 leaf_star_item ,请将它们提供给我,并使用 null 完成 leaf_star_stem_bud 信息。

LEFT JOIN LEFT OUTER JOIN

  • 向我提供所有 leaf_star_stem_bud ,其中包含 leaf_star_item
  • 如果还有更多 leaf_star_stem_bud ,请提供给我并使用 null 完成 leaf_star_item 信息。

了解更多信息:

What is the difference between Left, Right, Outer and Inner Joins?

http://en.wikipedia.org/wiki/Join_(SQL)