关于mysql isnull函数的一个小技巧

mysql isnull返回值为0或1

其中0不为null,1为null

这跟boolean取值正好相反,怎么能直接查询出跟boolean相对应的数据呢

只需要简单的在isnull前边加上“!”就行

select t.user_id,t.open_id,t.user_headurl,t.user_nickname,!ISNULL(t1.mgr_id) is_manager 
from fa_user t 
LEFT JOIN fa_manager t1 ON t.open_id=t1.mgr_openid

猜你喜欢

转载自blog.csdn.net/zml_moxueli/article/details/78355527