Guru Karthi R
Guru Karthi R

Reputation: 320

How to perform SELECT query on concatenated columns in RoomDB?

I have a table(user) with the structure

+-----+----------+------------+
|ID   |firstName |lastName    |
+-----+----------+------------+
|1    |John      |Wesley      |
+-----+----------+------------+
|2    |Ashley    |Copper      |
+-----+----------+------------+

Search query 'n W' should results 'John Wesley' and 'y C' should results 'Ashley Copper' out fo the table.

Upvotes: 2

Views: 72

Answers (3)

DeePanShu
DeePanShu

Reputation: 1326

Please try this:-

Select firstName,lastName from user where (firstName like "%y" and lastName like "C%") or (firstName like "%n" and lastName like "W%")

Upvotes: 0

Guru Karthi R
Guru Karthi R

Reputation: 320

Finally got the answer,

SELECT * FROM User WHERE ((firstName||" "||lastName)  LIKE %query%)

Upvotes: 2

Vishal Arora
Vishal Arora

Reputation: 2564

Use the following query on your Room Dao method -

SELECT user.firstName || user.lastName AS 'FULL_NAME' FROM User;

Upvotes: 0

Related Questions