如何在SQL中使用大于'case'的情况?
我有以下工作正常,但等于100:
select case (TIMESTAMPDIFF(SECOND,last_active,now())) when 100 then 'True' else 'False' end from sessions where uuid=11 and token='test';
如何为(> 100)提供相同的查询?
如果您需要更多说明,请与我们联系!
由于
答案 0 :(得分:2)
select case when (TIMESTAMPDIFF(SECOND,last_active,now())) > 100 then 'True' else 'False' end
from sessions where uuid=11 and token='test';
答案 1 :(得分:0)
CASE
有两种形式。
CASE expression WHEN Value THEN Value [ WHEN Value THEN Value ] ELSE Value END
和
CASE WHEN Expression THEN Value [ WHEN Expression THEN Value ] ELSE Value END
你想要后者。
SELECT case WHEN (TIMESTAMPDIFF(SECOND,last_active,now())) > 100 then 'True' else 'False' end
FROM sessions where uuid=11 and token='test';