In the Android Rooms persistence library, how would I write the following SQL statement as a @Query?
SELECT * FROM table WHERE field LIKE %:value%
This syntax is invalid, and I can't find anything about it in the documentation.
You can just concatenate using SQLite string concatenation.
@Query("SELECT * FROM table WHERE field LIKE '%' || :value || '%'")
The answer by yigit works great for me:
@Query("SELECT * FROM stores " +
"WHERE name LIKE '%' || :search || '%' " +
"OR description LIKE '%' || :search || '%'")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With