brown2005 Posted November 28, 2012 Share Posted November 28, 2012 (edited) $domain = 1; $user = 1; SELECT domains_ratings_domain, COUNT( * ) , AVG( domains_ratings_rating ) FROM domains_ratings WHERE domains_ratings_domain = $domain GROUP BY domains_ratings_domain I have this code which selects: domain 1 total number of ratings for domain 1 for all users average rating for domain 1 for all users what I also want to get is the rating that $user=1 has put in the table. Can this be done in the above code? or does it need to be separate? and how would I go about doing this please? Edited November 28, 2012 by brown2005 Quote Link to comment Share on other sites More sharing options...
Barand Posted November 28, 2012 Share Posted November 28, 2012 (edited) nm - needs more thought Edited November 28, 2012 by Barand Quote Link to comment Share on other sites More sharing options...
Barand Posted November 28, 2012 Share Posted November 28, 2012 (edited) try SELECT a.domains_ratings_domain, COUNT( * ) , AVG( a.domains_ratings_rating ) FROM domains_ratings a LEFT JOIN domain_ratings b ON a.domain_ratings_domain = b.domain_ratings_domain AND b.domain_ratings_userid = 1 WHERE a.domains_ratings_domain = $domain GROUP BY a.domains_ratings_domain Edited November 28, 2012 by Barand Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.