简体   繁体   English

如何在android sql搜索中使用[charlist] Wildcard

[英]How to use [charlist] Wildcard in android sql search

I tried to search a for name that starts with a or b or c, so I used this query: 我试图搜索以a或b或c开头的名称,所以我使用了这个查询:

db.rawQuery("SELECT _id, name, freq FROM dicttable WHERE name LIKE '[A,B,C]%'
    ORDER BY freq DESC LIMIT 0, 8", null);

It did not give null result or fail result, it just gave empty values which means it found nothing. 它没有给出null结果或失败结果,它只是给出了空值,这意味着它什么也没找到。 Can anyone guide me on this method? 任何人都可以指导我这个方法吗?

You can't do that sort of thing with LIKE . 你不能用LIKE做那种事情。 You'll need to use GLOB like so: 你需要像这样使用GLOB

...WHERE name GLOB '[ABC]*' ...

The * means anything else, so this will match any name that starts with A, B, or C and has anything else following it. *表示其他任何内容,因此这将匹配任何以A,B或C开头并且后面还有其他内容的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM