Mysql
 sql >> Database >  >> RDS >> Mysql

Sostituisci i valori nulli in sql usando l'istruzione select in mysql?

Hai molte opzioni per sostituire i valori NULL in MySQL:

CASE

select case 
    when fieldname is null then '123' 
    else fieldname end as fieldname 
from tablename 

COALESCE

select coalesce(fieldname, '123') as fieldname 
from tablename 

IFNULL

select ifnull(fieldname, '123') as fieldname 
from tablename