Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- `u`.`id`,
- `u`.`username`,
- CONCAT(`p`.`size`, 'KB') AS `size`
- FROM `users` `u`
- INNER JOIN `pictures` `p`
- ON `p`.`id` = `u`.`profile_picture_id`
- WHERE `profile_picture_id` IN(
- SELECT `profile_picture_id` FROM (
- SELECT
- `profile_picture_id`,
- COUNT(`profile_picture_id`) AS `pic_count`
- FROM `users`
- GROUP BY `profile_picture_id`
- HAVING `pic_count` > 1 #if someone has NULL profile_pic_id then the COUNT is 0 and skipped
- ) AS `cq`
- )
- ORDER BY `u`.`id` ASC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement