views:

766

answers:

2

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
+1  A: 

Select maximum from where?

SELECT MAX(colum_from_where_you_need_maximum) FROM (table_name)
Trick
You should try issuing `SELECT 1;` once. Databases can do a lot more than you think.
soulmerge
+10  A: 

Use GREATEST()

Eg:

SELECT GREATEST(2,1);
NinethSense
+1. Perhaps a look into the manual can be useful: http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_greatest
Stefan Gehrig