pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feed From: tjk@tksoft.com <tjk@tksoft.com>
To: asakmanas@grafton.lt
Cc: pgsql-sql@postgresql.org
Subject: Re: outer joins
Date: Wed, 4 Apr 2001 07:22:43 -0700 (PDT)
Message-ID: <200104041422.HAA10925@smtp3.tksoft.com> (raw )
In-Reply-To: <NFBBJHKIMLJDMKFOHEPEEECFCAAA.asakmanas@grafton.lt >
Algirdas,
This should do the trick:
SELECT a.id,b.name FROM a,b WHERE a.id=b.id UNION SELECT id,null FROM a WHERE id NOT IN (SELECT id FROM b);
Troy
>
> Hi all,
>
> I'm new to postgre, I've changed my work and consequently now i'm moving
> from MS plaform.
> In MS SQL there are such constructs left or right outer join, in postgres
> there are no such thing
>
> Can You offer me strategy to make query that selects from table (a) and
> joins to it another (b)
> on e.g. a.id=b.aid but joins so that in case there is no value in table b
> NULL is left in result:
> in MS SQL i've used query:
>
> select a.id, b.name from a left outer join b on a.id=b.aid
>
> table a table b
>
> id | aid | name
> ----------- ----------------
> 1 1 | Tom
> 2 3 | Sam
>
> result:
> a.id | b.name
> ---------------------
> 1 | Tom
> 2 | NULL
>
> thank you in advance
>
> Algirdas ©akmanas
> IT manager
> +370 99 90369
> asakmanas@grafton.lt
> Grafton Entertainment
> http://www.tvnet.lt
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
view thread (38+ messages) latest in thread
Message-ID: <200104041422.HAA10925@smtp3.tksoft.com>
Permalink: ../200104041422.HAA10925@smtp3.tksoft.com/
Also on: postgresql.org/message-id/200104041422.HAA10925@smtp3.tksoft.com
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tjk@tksoft.com, asakmanas@grafton.lt
Subject: Re: outer joins
In-Reply-To: <200104041422.HAA10925@smtp3.tksoft.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox