sql 语句if函数

SQL语句中的if函数使用,如果满足一个件条可以赋一个需要的值,方便代码判断 eg:


SELECT *,if(ebay_excludecountrymodel.id is null,'false','true') checked 
FROM ebay_exshiplocation e left join ebay_excludecountrymodel
on e.site=ebay_excludecountrymodel.site
 and e.id= ebay_excludecountrymodel.excludecountryid
 and ebay_excludecountrymodel.site=186 where e.site=186;
 SELECT `user`.realname, if(`user`.realname IS NULL , '有值' ,'无') checked 
 from user LEFT JOIN user_other_info ON `user`.id=user_other_info.id

这里写图片描述

猜你喜欢

转载自blog.csdn.net/maying0124/article/details/80679864