【发布时间】:2021-04-25 15:52:12
【问题描述】:
为什么我收到此查询错误?有什么我想念的吗?
所以如果“via”字段为 O,我想获取 online_date,然后如果“via”字段为 M,我想获取 manual_date
SELECT a.seqreq,
b.idfieldb ,
c.idfieldc ,
a.number_given,
case upper(a.via) when 'O' then 'Online'
when 'O' then 'Online'
when 'M' then 'Manual'
else a.via
end as via,
case when upper(a.via) when 'O' then a.online_date
when 'M' then a.manual_date //it says error on this line ?
else a.others_date
end as date_registered
from mytablea a
left join tbl_b b on a.idfielda=b.idfieldb
left join tbl_c c on a.idfielda=c.idfieldc
left join tbl_d d on a.userEntry=d.NoIdUser
错误信息:
W (1): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'when 'O' then
【问题讨论】:
-
case when upper(a.via) when 'O' then a.online_date=>case upper(a.via) when -
感谢塞尔格!我是多么愚蠢,没想到会这样:3