Order by number of votes

Im trying to retrieve items from my database ordering them by which one has the highest votes… it structured like this

id - title - votes
1- something - 3213, 34234, 65436, 23, 345, 54532
2- other - 342,
3- title - 123, 3562, 642
4- etc - 0
5- etc - 432424, 34243

the random numbers would stand for user id, and everytime a user votes, his id simply gets added to the field, seperated by a comma

so basicly i figure i would have to count the number of commas, and see which one has the most… making the order
1- something - 3213, 34234, 65436, 23, 345, 54532,
3- title - 123, 3562, 642,
5- etc - 432424, 34243,
2- other - 342,
4- etc - 0

also, how would i got about checking if the user already voted?

thanks

i urge you most strenuously to change this design

you are asking for a world of hurt – complex sql and performance worse than cold glue

what you want is a table with one row per user vote

then the sql becomes practically trivial and can easily be optimized

:slight_smile: