lunatique aldebaran
lunatique aldebaran

Reputation: 351

i want to get max value in to 2 colomn in mysql

i want to know how to get max value ini 2 colomn ini mysql, for example data like this :

table_a : Filed : value 1, value2,value 3

and i want to get max value between value1,value2,value3 form table_a .

please somebody can help me. thanks.

Upvotes: 0

Views: 56

Answers (1)

naqib83
naqib83

Reputation: 128

You may want to use the GREATEST() function:

SELECT GREATEST(value2, value2, value3);

But to get absolute maximum from all the rows, you may use:

SELECT GREATEST(MAX(value1), MAX(value2), MAX(value3)) FROM table_a;

Upvotes: 1

Related Questions