Guest User

Untitled

a guest
Aug 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. Two queries optimize
  2. SELECT `type`, COUNT(`id`) AS 'type' FROM `items` WHERE `post` = `id` GROUP BY `type`;
  3. SELECT `type`, COUNT(`post`!=`id`) AS 'posts' FROM `items` GROUP BY `type`;
  4.  
  5. SELECT `type`,
  6. COUNT(`post`=`id`),
  7. COUNT(`post`!=`id`) AS 'posts'
  8. FROM `items`
  9. GROUP BY `type`;
Add Comment
Please, Sign In to add comment