[英]greater than in case when in sql
在SQL中,如何使用大於'case when'的值?
我有以下工作正常,但等於100:
select case (TIMESTAMPDIFF(SECOND,last_active,now())) when 100 then 'True' else 'False' end from sessions where uuid=11 and token='test';
如何對(> 100)進行相同的查詢?
如果需要更多說明,請告訴我!
謝謝
select case when (TIMESTAMPDIFF(SECOND,last_active,now())) > 100 then 'True' else 'False' end
from sessions where uuid=11 and token='test';
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';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.