December 9th, 2012, 02:18 AM
Matching Query Results inside another Query Results
SELECT AID FROM TABLEA WHERE A1 = 1;
SELECT B.BID, A.AID FROM AID A, BID B WHERE A.AID = B.BID AND A1 = 1;
The first code above will give a list. (Ex. 1,2,3,6) I need to know if any BID have an AID list that at least have all the results of AID from the first code (Ex. 1, 2, 3, 4, 5, 6 GOOD) (Ex. 1, 2, 3, 5 BAD)
Basically, each AID is either positive or negative for A1. Each BID is either positive or negative with each AID. I need to know which BID is positive for ALL of "the positive AID."
December 9th, 2012, 01:34 PM
Re: Matching Query Results inside another Query Results
I solved it. All I need was a night of sleep and breakfast.
FROM TableA A, TableB B
WHERE A.AID = B.BID AND A.A1 = 1
HAVING COUNT(B.AID) = (
SELECT FROM COUNT(A.AID)
FROM AID A
WHERE A.A1 = 1)
GROUP BY B.BID
ORDER BY B.BID
Explanation: I got the total count of Horror films that exists. I compared the User's count of horror filmed they watched to that number. If any user has the same count, they show up.
Click Here to Expand Forum to Full Width