Japar S Japar S - 1 year ago 79
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?

Answer Source

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download