Re: SQL Query question

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: SQL Query question
Дата
Msg-id 200506301318.11588.peter_e@gmx.net
обсуждение исходный текст
Ответ на SQL Query question  ("Nick Stone" <nick@harelane.com>)
Список 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/


В списке pgsql-sql по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: ENUM like data type
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: SQL Query question