我有两个查询,它们非常复杂,所以我似乎无法弄清楚如何加入它们。
我想Q1.notAnyFewID = Q2.FBID
从两个查询中找到结果集
Q1:
SELECT DISTINCT notifications.`receiver` AS notAnyFewID
FROM notifications
JOIN
(SELECT notifications.`ref` AS notRef, notifications.`receiver` AS recI
FROM notifications
WHERE notifications.`ref`='tooFewLandings') AS c
ON notifications.`receiver`=c.recI
WHERE notifications.`receiver`!=c.recI
Q2:
SELECT DISTINCT R2PProfiles.id AS r2pID, R2PProfiles.`facebookID` AS FBID
FROM R2PProfiles
LEFT JOIN
(SELECT COUNT(*) AS Landings, R2PProfiles.facebookID, R2PProfiles.id
FROM pageTrack
JOIN (R2PProfiles)
ON (pageTrack.inputRefNum = R2PProfiles.id)
WHERE pageTrack.ref='getProfile-Land' AND R2PProfiles.published=2 AND R2PProfiles.`createTime`< NOW()- INTERVAL 24 HOUR GROUP BY R2PProfiles.id) AS h
USING (id) WHERE (Landings < 20)
当试图将它们结合起来时,我似乎总是在加入或子选择或“使用”或在哪里以及如何在正确的地方获得新的东西时搞砸了。
将其中一个查询与另一个查询的结果进行比较的最佳方法是什么?