sql中的左右连接
我试图在SQL中连接三个表。 我使用下面的查询,但它不工作sql中的左右连接
select *
from char_level as c1 right join (SELECT distinct character_id as fid, target_character_dbid as tid FROM house
where reason='set_house_access' or reason='remove_house_access' and character_id is not null and target_character_dbid is not null)as vd on c1.character_id==vd.fid left join char_level as c2 on c2.character_id==vd.tid
谁能帮助?
添加分号并使用单个等号。
select *
from char_level c1
right join
(SELECT distinct character_id as fid, target_character_dbid as tid
FROM house
where (reason = 'set_house_access'
or reason = 'remove_house_access')
and character_id is not null
and target_character_dbid is not null) vd
on c1.character_id = vd.fid
left join char_level c2
on c2.character_id = vd.tid;
它仍然给出错误 – 2013-05-13 20:48:50
也许你有两个语句连接成一个没有分号的单个语句。你有什么在线:38列:17?在Oracle的每个语句后都需要分号,否则您会收到此错误消息,[请参阅此处的示例](http://stackoverflow.com/questions/72151/ora-00933-sql-command-not-properly-ended)。我希望这有帮助! – criticalfix 2013-05-13 20:54:02
我试过了你发布的查询,但是stil出现了错误 – 2013-05-13 21:02:12
查询不执行:错误ORA-00933:SQL命令不能正确地结束 00933. 00000 - “SQL命令不能正确地结束” *原因: *动作: 行错误:38列: 17 – 2013-05-13 20:39:02
我期望结果应该是包含c1.account_id,vd.fid,vd.tid,c2.accoutn_id – 2013-05-13 20:40:10
的单个表Oracle对于表别名中的'AS'关键字有反感。删除它(除了其他更正,在答案。)'从char_level为c1'应该从'char_level c1'和')作为vd'应该变成:')vd' – 2013-05-13 21:08:49