dimanche 19 avril 2015

Group by not showing all the rows

I am working in wordpress and below is my select query. I have used leftjoin and group by. But only one row is returned if I have duplicate entries in my articles.username coloumn. So I want all the rows to be returned with group by and duplicates should be allowed in username field. PHP Code



$sqll = "SELECT articles.aid, articles.username, articles.competition, articles.path, articles.category, articles.title, Sum(zvotes.zvotes) AS votessum FROM articles LEFT JOIN zvotes on articles.aid=zvotes.aid GROUP BY articles.competition HAVING articles.category = '$cat' && articles.competition = '$comp' ORDER BY votessum";

$results = $wpdb->get_results($wpdb->prepare($sqll)) or die(mysql_error());


Thanks


Aucun commentaire:

Enregistrer un commentaire