MySql查询字段空为A不空为B

mysql数据库查询时,当字段为空是返回A,不为空时返回B

解决思路,通过mysql的if函数和isnull函数处理:

select id userId,if(ISNULL(cellphone),-1,0) from user

猜你喜欢

转载自wangning8075.iteye.com/blog/2366509