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 || '%'")