[英]SQL case when error
Hello my sql query still returns else case but I am pretty sure that inner select returns 1. What`s wrong with the code? 您好,我的SQL查询仍然返回其他情况,但是我很确定内部select返回1。代码有什么问题?
SELECT CASE a_from
WHEN (SELECT a_from REGEXP 'something.com>$' = 1 )
THEN "S"
ELSE "T"
END AS 'HP', a_from FROM article WHERE id =4
您可能在内部选择中缺少WHERE
(SELECT a_from REGEXP WHERE 'something.com>$' = 1 )
I think you missed the where
in your inner select statement. 我想你错过的
where
在你内心的select语句。
SELECT CASE a_from
WHEN (SELECT a_from REGEXP where 'something.com>$' = 1 ) <-- Here
THEN "S"
ELSE "T"
END AS 'HP', a_from FROM article WHERE id =4
As commented by ypercube you may try like this: 如ypercube所评论,您可以这样尝试:
SELECT CASE WHEN a_from REGEXP 'something.com>$' = 1
THEN 'S'
ELSE 'T' END AS hp, a_from
FROM article WHERE id = 4 ;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.