Mysql – How to get the max of two values in MySQL

maxMySQL

I tried but failed:

mysql> select max(1,0);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual 
that corresponds to your MySQL server version for the right syntax to use 
near '0)' at line 1

Best Answer

Use GREATEST()

E.g.:

SELECT GREATEST(2,1);

Note: Whenever if any single value contains null at that time this function always returns null (Thanks to user @sanghavi7)