How does the% field in the fuzzy query of the Android room database be represented by dynamic placeholders?

I want to do a fuzzy query for a third-level city, and then I thought of using Room to do local query. I
first made a demo of adding, deleting, modifying and checking the official documents and some articles. I found that there is no introduction about the like query and it is not very detailed. The
document has Similar to this, I can't try it. . .

 @Query("SELECT * FROM users WHERE last_name LIKE :strName")

Later, after consulting the data: I tried this, ok

 @Query("SELECT * FROM users WHERE last_name LIKE '%' || :strName || '%'")
    List<User> loadAllUserLike(String strName);//加一个占位符strName 表示%last_name%

If you have any questions, communicate with each other + WeChat yaxin_com

Guess you like

Origin blog.csdn.net/ShiXinXin_Harbour/article/details/113729172