Show the lowest value in MySQL

0

I'm doing a DB that shows the smallest value among three options, each option represents a column. I want to get the lowest value of a row where it contains these three values.

    
asked by anonymous 04.04.2017 / 16:42

1 answer

0

Use LEAST() :

SELECT LEAST(1,2,3);

Result:

1

It will return the smallest value between the values entered in the function .

In your case, do:

SELECT LEAST(ColunaA, ColunaB, ColunaC) FROM Tabela

This way you will get the smallest value between the three tables of each line.

    
04.04.2017 / 17:37