MySql query field is empty is A, not empty is B

When querying the MySQL database, when the field is empty, it returns A, and when it is not empty, it returns B

 

The solution is to deal with the if function and isnull function of mysql:

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

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326316682&siteId=291194637