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')
)