在Sqlite中搜索查询(Search query in Sqlite)

编程入门 行业动态 更新时间:2024-10-23 18:21:27
Sqlite中搜索查询(Search query in Sqlite)

我在数据库中有一些项目。 我使用“like”关键字过滤

查询: mCursor = mDb.query(listTable, new String[] { ID_rs, Item_name, item_code, Unit_code, Tot_Amt, dis_count, }, Item_name + " like '%" + mix + "%' ORDER BY " + Item_name + " ASC", null, null, null, null, null);

例:数据库中的值1.SAKTHI readymix 2.curry Mix 3.Mixture

我的结果:1.SAKTHI readymix 2.curry Mix 3.Mixture

但我需要“咖喱混合,混合物”作为我的输出我怎么能得到它。 帮帮我!

I am having some items in database. i filter using "like" keyword

Query:mCursor = mDb.query(listTable, new String[] { ID_rs, Item_name, item_code, Unit_code, Tot_Amt, dis_count, }, Item_name + " like '%" + mix + "%' ORDER BY " + Item_name + " ASC", null, null, null, null, null);

Ex: values in the database 1.SAKTHI readymix 2.curry Mix 3.Mixture

my result : 1.SAKTHI readymix 2.curry Mix 3.Mixture

But i need "curry Mix, Mixture" as my output how can i get that. help me out!

最满意答案

继续你的意见,

您可以尝试使用语法

Item_name + " like '" + mix + "%' OR " + Item_name + " like '% " + mix + "%'"

基本上,

第一个匹配以Item_name开头的, OR附加具有Space后跟Item_name的那些。 阿卡是一个新词。 (注意%之后的空格)

Going on your comments,

You could try using the syntax

Item_name + " like '" + mix + "%' OR " + Item_name + " like '% " + mix + "%'"

Where basically,

the first matches ones that start with Item_name, the OR attaches ones that have Space followed by Item_name. Aka are a new word. (note the space after the %)

更多推荐

本文发布于:2023-07-23 12:02:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1231659.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Sqlite   Search   query

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!