I have a query that pulls in some products, there are several products and the list will increase
TimedStamp DESC by ORDER from seed pid, link, made_at products But I also have another table that includes pid and rating The field is a link to the table of products pid . SELECT avig (rating) rating group pid How can I query so that it can remove information as below?
products.pid, products.link, products.created_at, avg (rating.Rating)
In MySQL, this should give you the desired results; SELECT p.pid, p.link, p.created_at, avg (r.rating) products by LEFT JOIN rating r ON p. Pid = r.pid GROUP BY p.pid; .
As a side note, MySQL is special because it lets you query incomplete GROUP BY , so if you want to run it on other databases (or possibly stylish reasons), the query is instead should be there;
= RPID Group by PPID, P.Link, P.Kerated_Att;
No comments:
Post a Comment