MySql 里的IFNULL、NULLIF和ISNULL用法
mybatis不能使用IFNULL这些函数,可以用case . . . when . . . then . . . else . . . end代替
select id,is_topic_on as topicOn,topic_name as topicName,topic_recommend as topicRecommend,topic_introduction as topicIntroduction,topic_group as topicGroup,
CASE WHEN (topic_user is null || (LENGTH(trim(topic_user))=0))THEN 0 ELSE 1 END as topicUser,CASE WHEN ((topic_community is null) or (LENGTH(trim(topic_community))=0)) THEN 0 ELSE 1 END as topicCommunity
from tbl_community_topic where id=#{id}
本文介绍在MyBatis中如何实现IFNULL等条件判断功能,通过CASE...WHEN...THEN...ELSE...END语句替代IFNULL函数进行空值检查及长度判断。
7035

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



