Code: Select all
system_ratings:
pkid, name, value
product_ratings:
pkid, rating_id, user_id, product_id, date, ratingFor instance with no product ratings (product_ratings records = 0) system_ratings would return the entire resultset ordered alphanumerically.
However if three people rated product ID = 3 four times so the table looked like:
Code: Select all
1, 1, 1, 1, 0, 4.4
2, 2, 1, 1, 0, 5.0
3, 3, 1, 1, 0, 2.0
4, 2, 2, 1, 0, 5.0
This would affect the default alphanumeric ordering to shift in favour of whatever rating_id = 2 would be as it had the most 'votes' -- make sense?
I am not overly fluent in SQL for anyting beyond a simple query so I'm not even sure where to start.
I assume I have to GROUP BY or similar but again I have no idea how to even start, every query I do have limits the results only to those that match exclusively, that is, an entry in one table exists in the other, when in reality what I need is the result set to list all items in system_ratings, but have the order be influenced/changed according to the number of items are found to relate back to the system_ratings table.
Cheers,
Alex