我正在尝试在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
任何人都可以帮忙吗?
答案 0 :(得分:2)
添加分号并使用单个等号。
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;