Japar S Japar S - 5 months ago 27
MySQL Question

Echo Record With MAX Value in Codeigniter

I want to echo record that has a MAX Value in php,So how i do that?

I have table like this:

1 | 3
2 | 1

What i've tried so far is use query
SELECT MAX(value) FROM user

but it just echo max user,so how i can show record with id that have MAX value in Codeigniter?


If you need only one row with actual data you should use another appoach with sorting and limit. See code below:

SELECT * FROM user order by value desc limit 1;