Reputation: 33
I want to create search for one of my sqlite3 tables. With a combination of a text-field or pull-down, the search should start after 3 letters have been entered and should return some recommendations which it found in the table. That's the idea at least.
For now I'm stuck at searching for a part of a string in the database.
"SELECT * FROM album WHERE artist='Audiosl'"
That does return a empty search as well as
"SELECT * FROM album WHERE artist LIKE 'Audiosl'"
Is there a way to do that?
Upvotes: 3
Views: 5582
Reputation: 1910
"SELECT * FROM album WHERE artist LIKE '%Audiosl%'"
would do your task.
This searches for string like T Audiosl
, Audiosl23
, T Audiosl23
, etc.
Refer for more : http://www.sqlite.org/lang_expr.html
Upvotes: 4
Reputation: 106400
Take a closer look into using the LIKE
SQLite operator. This would turn your statement into the following:
SELECT * FROM album WHERE artist LIKE 'Aud%'"
The %
matches on zero or more characters. There are more operators in the SQLite documentation as well.
Upvotes: 3
Reputation: 3348
SQLite includes an official full text search extension which provides functionality suitable for lots of text fields as your schema implies. You can do field style searches (artist:*a* album:"greatest hits") plus all the other stuff you would expect (NEAR, AND, OR, exclusions).
I strongly recommend you use this extension instead of building your own queries.
Upvotes: 0