Generally, when we use the ifnull() method, it is similar to the following statement:
IFNULL(expr1,expr2)
If expr1 is not NULL, IFNULL() returns expr1, otherwise it returns expr2. IFNULL() returns a number or string value
select ifnull(name,’no name’) from person;
Convert the null in the query result to the specified string, but in fact, you can also use ifnull() in the where query part:
select * from person where ifnull(name,’no name’)=’no name’;
This kind of use seems a bit stupid, but in some applications it can reduce the amount of code very well.
Read More:
- How to Solve can‘t connect to local mysql server through socket ‘/var/lib/mysql/mysql.sock‘
- How to Fix MySQL ERROR 1130 (HY000): Host ‘XXXX’ is not allowed to connect to this MySQL server
- How to Solve MYSQL Error: Failed to start MySQL 8.0 database server
- [Solved] Anaconda Error: pyqt can’t use QSqlDatabase to connect to MySQL
- Mysql :error 1111. Invalid use of group function
- How to Solve mysql [Err] 1067-Invalid default value for
- How to Check the most CPU consuming 50 queries in MYSQL
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)
- Mysql Flashback Warning: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe
- How to Fix MySQL error 1005: can’t create table (errno: 150)
- How to Solve Mysql8 load data error
- MySql Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
- [Solved] MYSQL Command Execute Error: Can ‘t connect to local MySQL server through socket ‘/tmp/mysql.sock ‘(2) “
- MySQL: How to Turn on Functions
- Docker: How to Solve MYSQL8 & Navicat remote connection error
- How to Solve MYSQL into outfile Error13
- How to Solve c3p0 connect mysql8.0 Error
- MySQL Install Error: MySQL error 1042: Unable to connect to any of the specified MySQL hosts
- MYSQL Use cmd to change root password error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual tha
- Remote connection to MySQL database error: is not allowed to connect to this MYSQL server solution