SQLite LIKE

Rusty

Well-Known Member
Licensed User
Longtime User
For the past year or so, I've been using:
SELECT * FROM
WHERE [FirstName] LIKE 'Pe%'
this used to select rows where FirstName STARTED with Pe (case insensitive)

Recently, this no longer works. (not sure why) The result of the query is NO rows selected. (I've verified that multiple rows have a FirstName beginning with Pe like Pete, Peter, Pedro...)

Now, I've been trying:
SELECT * FROM
WHERE [FirstName] LIKE '%Pe%'
This "works", but it returns rows that contain Pe, but it also returns any row where "Pe" (case insensitive) occurs anywhere within the FirstName column.
This insures me that the data is there; the database is (likely) not corrupted, but the results are not what I want. I only want Rows that the FirstName BEGINS with "Pe".

I don't know what has changed.
Any Ideas what I might be doing wrong?
Thanks,
Rusty
 

Mahares

Expert
Licensed User
Longtime User
On the surface your code looks correct. But, try this. It works for me:
B4X:
Dim txt as string
txt="SELECT * FROM MyTable WHERE FirstName LIKE ? "
Cursor1=SQL1.ExecQuery2(txt,Array As String("Pe%"))
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks for the suggestion.
I implemented your suggestion with the same results.
Rusty
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
tried checking the length of the returned strings? perhaps it can be a leading character, put at the import or insertion.
 
Upvote 0
Top