From: | "Joshua b(dot) Jore" <josh(at)greentechnologist(dot)org> |
---|---|
To: | Sharon Cowling <sharon(dot)cowling(at)sslnz(dot)com> |
Cc: | "Pgsql-Novice (E-mail)" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Incorrect Query |
Date: | 2002-05-08 13:39:09 |
Message-ID: | Pine.BSO.4.44.0205080744420.7197-100000@kitten.greentechnologist.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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')
)
From | Date | Subject | |
---|---|---|---|
Next Message | Joshua b. Jore | 2002-05-08 14:08:19 | Re: Appending values non-destructively |
Previous Message | Henshall, Stuart - WCP | 2002-05-08 10:58:15 | Re: Appending values non-destructively |