你好我的sql查询仍然返回else case但我很确定内部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
答案 0 :(得分:0)
你可能在内部选择
中缺少一个WHERE(SELECT a_from REGEXP WHERE 'something.com>$' = 1 )
答案 1 :(得分:0)
我认为你错过了内部选择陈述中的where
。
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
如ypercube所评论,您可以尝试这样:
SELECT CASE WHEN a_from REGEXP 'something.com>$' = 1
THEN 'S'
ELSE 'T' END AS hp, a_from
FROM article WHERE id = 4 ;