Skip to content

Instantly share code, notes, and snippets.

@Clorith
Created September 13, 2014 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Clorith/8b5ea2bdbef9b68cccb2 to your computer and use it in GitHub Desktop.
Save Clorith/8b5ea2bdbef9b68cccb2 to your computer and use it in GitHub Desktop.
SELECT
(
SELECT
COUNT(DISTINCT id)
FROM
messages
WHERE
nickname = '" . $_GET['nickname'] . "'
AND
is_question = 1
) AS questions,
(
SELECT
COUNT(DISTINCT id)
FROM
messages
WHERE
nickname = '" . $_GET['nickname'] . "'
AND
is_docbot IS NOT NULL
) AS docbot,
(
SELECT
COUNT(DISTINCT id)
FROM
messages
WHERE
is_appreciation LIKE ('%" . $_GET['nickname'] . "%')
) AS appreciation
FROM
messages
LIMIT 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment