At 10:39 PM 05-12-1999 -0500, Mike Mascari wrote:
>I would just do:
>
>SELECT users.usr_id, users.usr_login FROM users WHERE NOT EXISTS
> (SELECT wm_accounts.usr_id FROM wm_accounts WHERE
> wm_accounts.usr_id = users.usr_id);
OK, my current query is
select usr_id,usr_login from users where usr_id not in (select userid from
wm_accounts);
Your query on small test tables (after vacuum analyze):
Seq Scan on users (cost=1.83 rows=25 width=16)
SubPlan
-> Seq Scan on wm_accounts (cost=1.33 rows=2 width=4)
My query:
Seq Scan on users (cost=1.83 rows=25 width=16)
SubPlan
-> Seq Scan on wm_accounts (cost=1.33 rows=10 width=4)
What does rows mean? But it looks like your query is better :). Don't fully
understand why tho. Would it work if wm_accounts is empty?
>> I would prefer a query which can work if the second table is null. The
>> problem with other queries I thought of was they would return null if the
>> second table is null.
>>
>
>I'm not sure what you mean here. Do you mean the table doesn't exist, is
empty,
>or that the usr_id field is NULL?
I meant the table is empty.
>What happens if a record is added to wm_accounts? Do you want a record to
also
>be created in users as well, or is users a superset with respect to
wm_accounts
>and usr_id?
Users is a superset.
Thanks for your suggestion,
Link.
************