Pergunta

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

Foi útil?

Solução 2

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

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

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top