mysql 对查询为null的值赋默认值

查询两张表 并且对为空的值做默认值

select u.User_pictureUrl,u.User_phone,u.ID as userId,u.user_nickname,IFNULL(f.userFriend_status,3)as status ,IFNULL(f.userFriend_comment,' ')as userFriend_comment,IFNULL(f.userFriend_address,' ')as userFriend_address
 
from tab_userinfo u LEFT JOIN tab_userfriend f ON  u.ID=f.userFriend_user_id  where u.ID=#{userId}


你可能感兴趣的:(mysql)