Re: [GENERAL] null and =

From: Lincoln Yeoh <lylyeoh(at)mecomb(dot)com>
To: Mike Mascari <mascarm(at)mascari(dot)com>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] null and =
Date: 1999-12-06 07:00:10
Message-ID: 3.0.5.32.19991206150010.008a9450@pop.mecomb.po.my
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Edouard DESSIOUX 1999-12-06 09:19:32 How to select where ....
Previous Message Madarasz Karoly 1999-12-06 06:57:13 database GUI library for C,C++