Re: sql help

From: Lennart Jonsson <lennart_at_kommunicera.umea.se>
Date: 22 Jul 2002 13:45:06 -0700
Message-ID: <6dae7e65.0207221245.2f803dab_at_posting.google.com>


"John Gilson" <jag_at_acm.org> wrote in message news:<XrT_8.102131$Wi.26113119_at_twister.nyc.rr.com>...
> How's this:
>
> CREATE TABLE de_words
> (
> word1 CHARACTER VARYING(50) NOT NULL,
> word2 CHARACTER VARYING(50) NOT NULL
> )
>
> CREATE TABLE de_en_dict
> (
> de_word CHARACTER VARYING(50) NOT NULL,
> en_word CHARACTER VARYING(50) NOT NULL
> )
>

Here is another one using subqueries and the tables above:

SELECT de.word1 AS german1,

       de.word2 AS german2,
       (select coalesce(en_word, 'NIL') from 
		de_en_dict where de_word = de.word1) as english1,
       (select coalesce(en_word, 'NIL') from 
		de_en_dict where de_word = de.word2) as english2,
FROM de_en_dict AS dict1

Note that this will not work unless de_word is unique (subquery will return more than one row).

/Lennart

[...] Received on Mon Jul 22 2002 - 22:45:06 CEST

Original text of this message