How to search min value from four other different fields in mysql query?

codeigniter, mysql

Solution

Use LEAST:

SELECT
    package_id,
    LEAST(price, price_double, price_triple, price_quad) AS price
FROM package;

Problem

I want to search min value from four fields in mysql query, I have tried a lot of ways but didn't get it, right now I am searching only from one field, here are my fields. Table :packages ``` package_id price price_double price_triple price_quad ``` I want to search the min amount from four fields like in php function ``` min(price,price_double,price_triple,price_quad). ``` but I want to implement it in mysql query how can this be possible? please help me. thanks in advance.

Original source

Related problems