jsqlparser无法解析where条件后面的case子句么?(mysql)

天机痕迹 2017-11-27 09:26:44
select * from test where 1=1 and case when 1=1 then 1=1 else 1=1 end;
类似这样的语句全都解析不了.
报错信息
net.sf.jsqlparser.JSQLParserException
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:56)
at zhztest.SqlUtil.removeOrderBy(SqlUtil.java:51)
at zhztest.SqlUtil.main(SqlUtil.java:38)
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered " "CASE" "case "" at line 1, column 35.
...全文
665 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hzs0502030128 2019-02-28
  • 打赏
  • 举报
回复
最新版本已经支持
天机痕迹 2017-11-28
  • 打赏
  • 举报
回复
引用 2 楼 yuxiangaaaaa 的回复:
[quote=引用 1 楼 yuxiangaaaaa 的回复:] select id,(case id when 1 then 1 else 1 end) from test where 1=1;
select id,(case when 1=1 then 1 else 1 end) from test where 1=1;[/quote] where 条件后面的
自由自在_Yu 2017-11-28
  • 打赏
  • 举报
回复
引用 1 楼 yuxiangaaaaa 的回复:
select id,(case id when 1 then 1 else 1 end) from test where 1=1;
select id,(case when 1=1 then 1 else 1 end) from test where 1=1;
自由自在_Yu 2017-11-28
  • 打赏
  • 举报
回复
select id,(case id when 1 then 1 else 1 end) from test where 1=1;
墨笙弘一 2017-11-28
  • 打赏
  • 举报
回复
楼上加一 我当时写存储也遇到同样的额问题,case when 返回的是一个值 你直接where 1=1 and 1 当然是会报错的
自由自在_Yu 2017-11-28
  • 打赏
  • 举报
回复
引用 3 楼 u012907818 的回复:
[quote=引用 2 楼 yuxiangaaaaa 的回复:] [quote=引用 1 楼 yuxiangaaaaa 的回复:] select id,(case id when 1 then 1 else 1 end) from test where 1=1;
select id,(case when 1=1 then 1 else 1 end) from test where 1=1;[/quote] where 条件后面的[/quote] select * from test where 1=1 and (case when 1=1 then 1 else 2 end)=1; case when结果是一个值,如果在where条件后面最后要等于一个值

50,545

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧