Skip to content Skip to sidebar Skip to footer

Wildcard Not Working In Sqlite

I keep trying to use wildcards in a search in an android app, and keep running into errors. I'm performing a search on my application using the string below: Cursor c_name = b.que

Solution 1:

Append the % to the query parameter.

I.E.:

Cursor c_name = b.query("namedrxns", newString[] { "_id", "name" },
          "name LIKE ?", newString[] { "%"+query+"%" }, null, null, null);

Like Thomas Mueller already said, please note that % and _ within the value still work as wildcards.

Solution 2:

The following should work (but I didn't test it with SQLite):

"name LIKE '%' || ? || '%'"

Please note that "%" and "_" within the value still work as wildcards.

Post a Comment for "Wildcard Not Working In Sqlite"