所以我试图将一些东西从MySql转换为MSSQL 2012,问题是我不知道Sql很清楚这个语句有什么问题。当我使用与MSSQL DB相同的信息对MySql DB运行时,我得到一个响应。
我收到错误:
关键字'where'附近的语法不正确。消息:156,等级:15,状态:1,程序:,行:11
select distinct
coalesce(s.state_prov, ls.state_prov, 'State Unknown') as state_prov
from
circuit_id_locations cid
join
location_states ls
left join
location_states s
on
cid.state_prov = s.abreviation
where
ls.idx = '99'
or
cid.id = '99'
答案 0 :(得分:1)
你有一个没有'on statement'的连接语句
>>>MISSING JOIN TYPE (inner/left/right/cross)<<< join
location_states ls
>>>MISSING ON<<<
左连接 location_states s
答案 1 :(得分:1)
您的JOIN
条款比ON
条款多CROSS JOIN
,将您的正常加入转为select distinct
coalesce(s.state_prov, ls.state_prov, 'State Unknown') as state_prov
from
circuit_id_locations cid
CROSS join
location_states ls
left join
location_states s
on
cid.state_prov = s.abreviation
where
ls.idx = '99'
or
cid.id = '99'
以使其有效。
{{1}}