Re: Possible use of a subselect? - Mailing list pgsql-novice

From Manfred Koizar
Subject Re: Possible use of a subselect?
Date
Msg-id 8eo3fu4qq1g5qcnbsg3hoai9l41htrckiu@4ax.com
Whole thread Raw
In response to Possible use of a subselect?  ("Adam Erickson" <adamre@cox.net>)
Responses Re: Possible use of a subselect?
List pgsql-novice
On Sun, 26 May 2002 23:43:50 -0500, "Adam Erickson" <adamre@cox.net>
wrote:
>Given the table structure:
>string
>------
>id serial int4
>stringid int4 not null
>language varchar(32)
>content varchar(255)
>
>I'm trying to get a query that will return the
>English version of every string ("SELECT id,content FROM STRING WHERE
>language='English' and stringid=0") and their translated counterpart (say,
>Korean) which would be ("SELECT content FROM string WHERE
>stringid=ID.OF.ENGLISH.VERSION").

Adam,
no need for a subselect.  Try an outer join:

SELECT e.id, e.content, k.content
FROM string e LEFT JOIN string k
    ON e.id = k.stringid
WHERE e.stringid = 0 AND k.language = 'Korean';

HTH.
Servus
 Manfred

pgsql-novice by date:

Previous
From: Rasmus Mohr
Date:
Subject: Re: Copy Comand question
Next
From: Manfred Koizar
Date:
Subject: Re: Possible use of a subselect?