From: Peter Eisentraut <peter_e@gmx.net>
To: Nick Stone <nick@harelane.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: SQL Query question
Date: Thu, 30 Jun 2005 13:18:10 +0200
Message-ID: <200506301318.11588.peter_e@gmx.net> (raw)
In-Reply-To: <20050630092944.E94022514BD@smtp.nildram.co.uk>
References: <20050630092944.E94022514BD@smtp.nildram.co.uk>
Am Donnerstag, 30. Juni 2005 11:27 schrieb Nick Stone:
> SELECT
> tbl1."TermTypeID",
> tbl1."ParentID",
> tbl1."KeywordID",
> tbl1."Term",
> tbl2."KeywordID"
> FROM
> "Terms" As tbl1 LEFT JOIN
> "SearchStore" As tbl2 ON tbl1."KeywordID" = tbl2."KeywordID"
> WHERE
> (tbl1."TermTypeID" >= 200) AND
> (tbl1."TermTypeID" < 600) AND
> (tbl1."IsSynonym" = false) AND
> (tbl1."LanguageID" = 1) AND
> (tbl2."StockID" = 1)
> ORDER BY
> tbl1."TermTypeID",
> tbl1."Term";
>
> Just to be obvious both queries as far as I can should return everything
> from Terms and anything if it exists from SearchStore subject to the WHERE
> clause parameters - obviously!
The condition (tbl2."StockID" = 1) will remove all rows that have null values
in the tbl2 fields, thus making your left join useless. Perhaps you should
change that to (tbl2."StockID" = 1 OR tbl2."StockID" IS NULL) -- or use your
first version.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
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: peter_e@gmx.net, nick@harelane.com
Subject: Re: SQL Query question
In-Reply-To: <200506301318.11588.peter_e@gmx.net>
* 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