How to implement ternary conditional operator in MySQL December 31, 2022 by Tarik Try this : select if(Id is null, 0, id) as Id;