问题
In Android Rooms persistence library, how would I write the following SQL statement:SELECT * FROM table WHERE field LIKE %:value%
As a @Query?
This syntax is invalid, and I can't find anything about it in the docs.
回答1:
You can just concat using SQLite string concatenation.
@Query("SELECT * FROM table WHERE field LIKE '%' || :value || '%'")
回答2:
Annswer by @yigit works great for me:
@Query("SELECT * FROM stores " +
"WHERE name LIKE '%' || :search || '%' " +
"OR description LIKE '%' || :search || '%'")
来源:https://stackoverflow.com/questions/44234644/android-rooms-search-in-string