Re: SQL

From: Andrew Gould <andrewgould(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL
Date: 2000-11-08 19:06:37
Message-ID: 20001108190637.25363.qmail@web122.yahoomail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I think you need to use a LEFT JOIN in your SQL
statement. I'm not sure how well PostgreSQL supports
JOINs, but the following might work:

select tablea.banid, tablea.flags, tableb.banid from
tablea left join tableb on tablea.banid = tableb.banid
where tableb.banid = null and tablea.flags not like
'%v%';

--- Randy Jonasz <rjonasz(at)click2net(dot)com> wrote:
>
> Hi everyone,
>
> I have a quick question. If anyone could help me
> that would be great. I
> have two tables in postgres.
>
> table a
> banid int4 primary key,
> flags varchar(64)
>
>
> table b
> banid int4 foreign key
> validate int4
>
>
> What SQL statement would allow me to search for
> records in table a which
> are not in table b. The additional constraint is
> that I only want records
> from table a which do not have 'v' in the flags
> column.
>
> Here's an example SQL statement I've been using but
> I'm thinking it is
> flawed.
>
> SELECT distinct a.banid FROM a,b WHERE a.banid !=
> b.banid AND a.flags NOT
> LIKE '%v%';
>
> Any help would be most welcome!
>
> Randy Jonasz
> Software Engineer
> Click2net Inc.
> Web: http://www.click2net.com
> Phone: (905) 271-3550
>
> "You cannot possibly pay a philosopher what he's
> worth,
> but try your best" -- Aristotle
>

__________________________________________________
Do You Yahoo!?
Thousands of Stores. Millions of Products. All in one Place.
http://shopping.yahoo.com/

Browse pgsql-general by date

  From Date Subject
Next Message mike focosi 2000-11-08 19:43:49 Increasing 8k row limit
Previous Message Bruce Momjian 2000-11-08 18:29:52 Re: VACUUM AND VACUUM ANALYSE