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

2007-08-17 Thread Carlos Ortíz
#x27;s not correct, but I'm new in postgresql. In sql server it's ok) De: [EMAIL PROTECTED] en nombre de Raymond O'Donnell Enviado el: Vie 10/08/2007 03:07 p.m. Para: 'PostgreSQL' Asunto: [GENERAL] SQL question: checking all required it

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"

[GENERAL] SQL question: checking all required items

2007-08-10 Thread Raymond O'Donnell
Hi all, Given the following tables - create table people ( person_id text primary key, person_name text, [...etc...] ); create table items ( item_id text primary key, item_name text, is_required boolean, [...etc...] ); create table items_for_people ( p