keval
keval

Reputation: 155

SQL - Combine multiple column and apply ILIKE

I am using PostgreSql and I have user table with firstName and lastName column. Please check below table as a example

----------------------------------------------------
id | firstname | lastName
----------------------------------------------------
1  | Keval     | Gangani
----------------------------------------------------
2  | New       | User
----------------------------------------------------

My pg query is SELECT * FROM users WHERE ("firstname" ILIKE %Keval Gangani% OR "lastName" ILIKE %Keval Gangani%) but this return zero results.

I know there is no records with %Keval Gangani%

I want to combine firstName and lastName and then i want to apply ILIKE query.

Upvotes: 2

Views: 1054

Answers (1)

keval
keval

Reputation: 155

SELECT * FROM users WHERE concat(firstname,' ',lastName) ILIKE '%Keval Gangani%'

Thanks to @Philippe

Upvotes: 2

Related Questions