Draw The Highest Value Out Of A Mysql Database Column

96 views Asked by At

I have a database "videos". Which has a table for each video i.e "ID" "Name" "Link" "Count". i want to be able to take the highest value of any of the tables from the column "Count" and then use which ever has the highest values "Link" Column.

So the best way i can explain is i'm trying to make a "Most Viewed" part of my site so which ever has the highest hit count gets displayed via $row['link'].

Hope this made sense didn't much to me!

Thanks all in advance...

2

There are 2 answers

0
MajorCaiger On BEST ANSWER
SELECT `link` FROM `someTable` ORDER BY `Count` DESC LIMIT 1

This will give you the link of the row with the highest count.

0
DhruvPathak On
SELECT `id`,`name`,`link`,`count` from my_table order by `count` desc limit 5;

This will give you 5 most viewed links.

Tip : You should not use words like count as column names as they are MySQL keywords.