Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use [charlist] Wildcard in android sql search

Tags:

sql

I tried to search a for name that starts with a or b or c, so I used this query:

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. Can anyone guide me on this method?

like image 947
Ricky Avatar asked Nov 24 '25 14:11

Ricky


1 Answers

You can't do that sort of thing with LIKE. You'll need to use GLOB like so:

...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.

like image 175
Dan Avatar answered Nov 26 '25 06:11

Dan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!