case…when…then语句,相当于编程语言中if判断
例1根据IsUser字段查询学生是否在线
select a.StudentID, (case a.IsUse
when '0' then '未在线'
when '1' then '在线' else '未上传' end) as 在线情况
from StudentBindPaperTypeEntity as

本文解析了SQL中的case...when...then结构,如何用它来实现类似编程中的if条件判断,通过实例说明如何根据IsUser字段查询学生在线状态,包括'未在线'、'在线'和'未上传'的不同情况。
case…when…then语句,相当于编程语言中if判断
例1根据IsUser字段查询学生是否在线
select a.StudentID, (case a.IsUse
when '0' then '未在线'
when '1' then '在线' else '未上传' end) as 在线情况
from StudentBindPaperTypeEntity as


被折叠的 条评论
为什么被折叠?