Search code examples
androidandroid-roomandroid-architecture-components

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.


Solution

  • Finally got the answer,

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