Re: boolean logic expressed in RDBMS rows
Date: 10 May 2003 20:28:18 -0700
Message-ID: <c0d87ec0.0305101928.1da48742_at_posting.google.com>
>> My question is - is there a 'standard' way to store the query
criteria inside a table(s) of any shape or form and what would that
table or tables look like? <<
You use a table of search values. If you want to OR them, then use a simple
SELECT ...
FROM Foobar
WHERE x IN (SELECT search_x FROM SearchList);
If you want to AND the search list, use a relational division. There is Exact Division and division with a remainder. That is, does the item returned have exactly that set of values or does it have at least that set of values? Here is one way to write exact relational division. The dividend table must match exactly to the values of the divisor without any extra values.
SELECT …
FROM Foobar AS F1
LEFT OUTER JOIN
SearchList AS S1
ON F1.x = S1.serch_x
GROUP BY F1.pilot
HAVING COUNT(F1.x) = (SELECT COUNT(search_x) FROM SearchList)
AND COUNT(S1.search_x) = (SELECT COUNT(search_x) FROM SearchList);
You can play with the equality test to get a remainder division. Received on Sun May 11 2003 - 05:28:18 CEST
