Re: Incorrect Query

Поиск
Список
Период
Сортировка
От Joshua b. Jore
Тема Re: Incorrect Query
Дата
Msg-id Pine.BSO.4.44.0205080744420.7197-100000@kitten.greentechnologist.org
обсуждение исходный текст
Ответ на Incorrect Query  (Sharon Cowling <sharon.cowling@sslnz.com>)
Список pgsql-novice
Sharon,
You were abusing parentheses and confusing the issue. Don't do that, it
just makes the query less readable.

Here is what you actually wrote:

where
person_id = ''
or
(
   (
       firstname = initcap('sharon')
   )
   or
   (
       lastname = initcap('cowling')
   )
)
or
(
   (
       firstname = initcap('sharon')
       and
       lastname = initcap('cowling')
   )
)

Which is simplified to (removing parentheses where redundant but
retaining all the logic). Check out that first bit where you match on
fname or lname. That last bit doesn't even do anything since the other
name expressions covered it already.

where
person_id = ''
or
firstname = initcap('sharon')
or
lastname = initcap('cowling')
or
(
   firstname = initcap('sharon')
   and
   lastname = initcap('cowling')
)

Why not just use?

WHERE person_id = ''
OR (firstname = initcap('sharon')
    AND
    lastname = initcap('cowling')
   )


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

Предыдущее
От: Andre Dubuc
Дата:
Сообщение: Appending values non-destructively
Следующее
От: "Joshua b. Jore"
Дата:
Сообщение: Re: Appending values non-destructively