Hi Phil,
Thanks for joining the discussion!
psandler wrote:
I believe this was a typo:
Remove the last "s" from that line ("QLIndice" instead of "QLIndices")?
My array was called QLIndices, though using plural may not be best practice ( id equals array generates 'select where id in (...)' behind the scenes in LLBL), so I think is was correct.
psandler wrote:
However, I think this is still not going to give you the results that you want. I believe adding all your predicates with "AND" instead of "OR" will result in never getting any records back, as a single row can't have more than one qualification level Id.
Someone actually asked a very similar question in another thread today--please see my response to that. What you are trying to do is actually much trickier than it may seem at first glance.
http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=8973
Phil
It is indeed tricky and I have had some trouble trying to construct the sql so I could present it in this thread and say "how to do this?". The only solution I've found so far is
SELECT
*
FROM
Supplier s
WHERE s.id in ("select those with qualificationA") and s.id in ("select those with qualificationB")...
I'm not sure I would want such a construct in my solution ;-)
As to your suggestion in the other thread, I think
SELECT
orderId
FROM
[order details] o
INNER JOIN products p ON o.productid = p.productid
WHERE
p.productid = 11
OR p.productid = 42
OR p.productid = 72
GROUP BY
o.orderId
HAVING
--"3" is the number of products we are filtering on
COUNT(p.productId) = 3
would exclude Orders that had all the required products but also other products, would it? And removing the COUNT requirement would mean getter the product requirements OR'ed. It's indeed closer, but still not quite what I was looking for.
I have made the quick-and-dirty solution for now (getting the gross list and filtering in code on the web server), but would like to switch to 'the correct solution' for performance and esthetics.