This works fine to return all longer-than-10-character strings from my Android SQLite database:
cursor = ___database.query(TABLE_NAME, mColumns, "length(word) > 10",
null, null, null, null);
Why doesn't this?
cursor = ___database.query(TABLE_NAME, mColumns, "length(word) > ?",
new String[]{"10"}, null, null, null);
P.S. SO suggested adding Tag regex, but Android SQLite doesn't support it... does it? I mention this because maybe length doesn't work like I expect, either....
But:
length(X) For a string value X, the length(X) function returns the number
of characters (not bytes) in X prior to the first NUL character. Since SQLite
strings do **not normally** contain NUL characters, the length(X) function will
**usually** return the total number of characters in the string X. For a blob value
X, length(X) returns the number of bytes in the blob. If X is NULL then
length(X) is NULL. If X is numeric then length(X) returns the length of a
string representation of X.
Aucun commentaire:
Enregistrer un commentaire