- Code: Select all
$sql = 'SELECT u.user_id, u.username, COUNT(*) as postings
FROM ' . USERS_TABLE . ' u, ' . POSTS_TABLE . " p
WHERE p.poster_id = u.user_id
AND p.poster_ip = '{$post_info['poster_ip']}'
AND p.poster_id <> {$post_info['user_id']}
GROUP BY u.user_id
ORDER BY postings DESC";
suffers from the GROUP BY problem because u.username needs to be in the group by clause.