Skip to content

Instantly share code, notes, and snippets.

@GRMule
Created October 29, 2014 16:36
Show Gist options
  • Save GRMule/1fb03dc0dd779762bfc3 to your computer and use it in GitHub Desktop.
Save GRMule/1fb03dc0dd779762bfc3 to your computer and use it in GitHub Desktop.
SELECT
`media`.`id`
FROM
`media`
WHERE
(
`published` = '1' AND
`waitingForModeration` = '0'
) AND (
`media`.`id` IN (
SELECT
`itemId`
FROM
`cmcCMS`.`tagItems`
WHERE
`tagId` IN (118,4)
GROUP BY itemId
HAVING (COUNT(tagId) = 2)
)
) AND (
`media`.`id` NOT IN (
SELECT
`itemId`
FROM
`cmcCMS`.`tagItems`
WHERE
`tagId` IN (122,452,612)
)
)
ORDER BY
`media`.`postedOn` DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment