Hi.
Did not test it, but something like the following would probably do
the job:
SELECT p.elementNAME,
SUM( IF( (e.elementID IN (A,B,C)), 0, 1 ) ) AS wrong_hits
FROM element p, element e
WHERE p.packageID = '0' AND
e.packageID = p.elementID
GROUP BY p.elementID
HAVING wrong_hits = 0
If you have a lot of 'wrong_hits', this may get significantly slower.
Bye,
Benjamin.
On Fri, Mar 03, 2000 at 03:05:00PM -0800, ted@stripped wrote:
> Ok, I've basically got an answer. With regards to the second
> question: I first query the database for all packages with
> elements not in the set (in this example, everything not in
> A, B, C). Then I query the database again for all packages
> containing any of the elements in the set BUT where the
> packages are not in the set of packages returned in the
> first query. For the first question: The SQL is as follows
> (provided by Nicholas Prade)
> Hello.
> Supposing
> - elementID is unique
> - your table name is: element
> - A,B and C are the 3 element's IDs
> You can try:
>
> SELECT p.elementNAME, COUNT(e.elementID) AS nb
> FROM element p, element e
> WHERE p.packageID='0' AND e.packageID=p.elementID
> AND e.elementID IN (A,B,C)
> GROUP BY p.elementID HAVING nb=3
>
[...]