Mahendra Chhimwal Mahendra Chhimwal - 1 year ago 56
SQL Question

Sqlite query to find all rows where a particular column field value lies in input string

I got a scenario where I have to find all rows in Android SQLite db, where a particular column field value lies in the input string. For example,
Input string:

I am not done yet, I can’t call it a day I need to work more for couple of hours.

Now my table in SQLite(Android) has a column called Title

I need to find all rows whose Title column field values lies in above input string. Basically I want following rows
where the full Title string is like one of below

  1. call it a day

  2. am not done yet

I want to know if it is possible using a single query in sqlite Android or not. What I know is LIKE query work on opposite manner.

Answer Source

Given that your table contains a column title which has titles that you want to match in the given string, you can do concatenation with % to use LIKE

select *
from your_table
where 'your input string here' like '%' || title || '%'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download