Minja
Minja

Reputation: 33

Sqlite, How to check is string contained in any value in database

I have username made of firstname+lastname+'some number' like "johndoe123" as a string in Android. And I have sqlite table with frequent English first and last names. Table "names" with column "firstName" and column "lastName".

Upvotes: 0

Views: 69

Answers (1)

forpas
forpas

Reputation: 164099

To get the rows from the table names that are contained inside the username johndoe123 you can use the operator LIKE:

select * from names 
where 'johndoe123' like '%' || firstname || '%' or 'johndoe123' like '%' || lastname || '%'

Upvotes: 1

Related Questions