2014-09-01 39 views
2

大家好新的数据库外连接和内连接修改下面的代码从右外连接没有得到相同的结果不知道为什么(= *)

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 

但查询没有得到相同的结果,能否请你帮我出

+0

如果您使用加入,你必须参加所有列。不要混合加入,并在那里为''cosmic_tank使用 – Jens 2014-09-01 06:43:12

+0

适当INNER JOIN语法'cosmic_tank'以及 – cha 2014-09-01 06:43:16

+0

仁则说,他们语法的修改是做 – user2045810 2014-09-01 06:45:32

回答

1

INNER JOINJOIN

  • 给我你所有leaf_star_stem_bud具有leaf_star_item与其关联。

RIGHT JOINRIGHT OUTER JOIN

  • 给我你所有leaf_star_stem_bud具有leaf_star_item与其关联。
  • 如果有更多的leaf_star_item,给我他们和完整leaf_star_stem_bud与信息。

LEFT JOINLEFT OUTER JOIN

  • 给我你所有leaf_star_stem_bud具有leaf_star_item与其关联。
  • 如果有更多的leaf_star_stem_bud,给我他们和完整leaf_star_item信息。

欲了解更多信息:

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

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

相关问题