Re: [GENERAL] SQL question: checking all required items

2007-08-17 Thread Carlos Ortíz
? Try Select * from people where person_id in ( Select person_ID from Items_for_people group by Person_id Having Count(*) = ( Select count(*) from Items Where is_required = true)) Or something like that. That's the idea. Probe it and tell us. (May be the sintaxis it's not corr

Re: [GENERAL] SQL question: checking all required items

2007-08-11 Thread Raymond O'Donnell
On 10/08/2007 21:42, Scott Marlowe wrote: Show us the query when you're done, I'm sure there are enough folks who'd like to see your solution. Here's what I came up with: select distinct ip.person_id from items_for_people ip where exists ( ( select item_id from items where

Re: [GENERAL] SQL question: checking all required items

2007-08-11 Thread Raymond O'Donnell
On 10/08/2007 22:03, Carlos Ortíz wrote: Select * from people where person_id in ( Select person_ID from Items_for_people group by Person_id Having Count(*) = ( Select count(*) from Items Where is_required = true)) That seems to work fine! I'd only change "having count(*) = .

Re: [GENERAL] SQL question: checking all required items

2007-08-10 Thread Scott Marlowe
On 8/10/07, Raymond O'Donnell <[EMAIL PROTECTED]> wrote: > On 10/08/2007 21:29, Scott Marlowe wrote: > > > > select table1.id from table1 where table1.id is not in (select id from > > table2); > > Duh! I should have thought of that thanks for that, and apologies > for the stupidity (blame it o

Re: [GENERAL] SQL question: checking all required items

2007-08-10 Thread Raymond O'Donnell
On 10/08/2007 21:29, Scott Marlowe wrote: select table1.id from table1 where table1.id is not in (select id from table2); Duh! I should have thought of that thanks for that, and apologies for the stupidity (blame it on the glass of wine I had with dinner!). Ray. --

Re: [GENERAL] SQL question: checking all required items

2007-08-10 Thread Scott Marlowe
On 8/10/07, Raymond O'Donnell <[EMAIL PROTECTED]> wrote: > - how can I find those people who don't have _all_ of the items which > are marked "required"? > > In other words, how do I select those rows in "people" which don't have > a corresponding row in "items_for_people" for *each* row in "items"