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

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

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

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top