Reputation: 5121
I have a table with two columns: first_name
and last_name
. At the application the user sees the full name (eg first + last names).
Example:
first_name last_name
bat man
Barack Obama
In the application if the user searches for "bat man" he got no result.
So, how can I filter using both columns?
My current sql:
select *
from people
where first_name ilike 'bat man'
or last_name ilike 'bat man'
Upvotes: 0
Views: 39
Reputation: 183300
You're looking for the string concatenation operator, ||
:
SELECT *
FROM people
WHERE (first_name || ' ' || last_name) ILIKE 'bat man'
See §9.4 "String Functions and Operators" in PostgreSQL 9.4.4 Documentation.
Upvotes: 2