Question

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...

Was it helpful?

Solution 2

SELECT `link` FROM `someTable` ORDER BY `Count` DESC LIMIT 1

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top