Created
October 29, 2014 17:03
-
-
Save Danack/1fde50e853fd6876f43d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TEMPORARY TABLE mediaSelected ( | |
mediaId int, | |
itemId int | |
); | |
CREATE TEMPORARY TABLE mediaRejected ( | |
mediaID int, | |
itemID int | |
); | |
insert into mediaSelected | |
SELECT | |
`mediaId`, | |
`itemId` | |
FROM | |
`cmcCMS`.`tagItems` | |
WHERE | |
`tagId` IN (118,4) | |
GROUP BY itemId | |
HAVING (COUNT(tagId) = 2); | |
insert into mediaRejected | |
SELECT | |
`mediaId`, | |
`itemId` | |
FROM | |
`cmcCMS`.`tagItems` | |
WHERE | |
`tagId` IN (122,452,612); | |
SELECT | |
`media`.`id` | |
FROM | |
`media` | |
left join mediaSelected | |
on mediaSelected.mediaId = media.id | |
left outer join mediaRejected | |
on mediaRejected.mediaId = media.id | |
ORDER BY | |
`media`.`postedOn` DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment