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

来源:互联网 发布:cf活动领枪软件 编辑:程序博客网 时间:2024/05/19 23:26

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

原创粉丝点击