From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | "Nick Stone" <nick(at)harelane(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: SQL Query question |
Date: | 2005-06-30 11:18:10 |
Message-ID: | 200506301318.11588.peter_e@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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/
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2005-06-30 11:22:17 | Re: SQL Query question |
Previous Message | Peter Eisentraut | 2005-06-30 11:13:05 | Re: ENUM like data type |