How can I get the exact word in a sentence

StuartDTO :

If I do this query, I search on a field that contains :

[Water, coke, 7up]

[Coke, water, 7up]

So, then I want also to return these items even if the parameter is written with capital letter, for this I'm using this @Query

@Query("SELECT * from drinksList WHERE list LIKE '%'||:name||'%'")

What am I missing?

EDIT

Now I'm using LIKE %param%but the problem is that if the table is like this :

[Water, coke, 7up]

[Coke, waterera, 7up]

[Waterg3d, coke, 7up]

[Coke, water23, 7up]

And I want to find the "water" one it will show all of these records, and I just want to find the word "water" doesn't matter if it's lowercase or uppercase.

MikeT :

The following should work :-

@Query("SELECT * from drinksList WHERE list||',' LIKE '%'||:name||',%' OR list||',' LIKE :name||',%'")

This based upon/ was tested using :-

DROP TABLE IF EXISTS DrinksList;
CREATE TABLE IF NOT EXISTS DrinksList (list TEXT UNIQUE NOT NULL);
INSERT INTO DrinksList VALUES
    ('Water, spicy, coke'),             -- Should be found when searching for water
    ('Coke'),                           -- will not be found when seraching for water
    ('Spicy, water, coke'),             -- Should be found
    ('Coke, spicy, water'),             -- Should be found
    ('wateria, spicyer, cokeer'),       -- should not be found
    ('Water, coke, 7up'),               -- should be found
    ('Coke, waterera, 7up'),            -- should not be found
    ('Waterg3d, coke, 7up'),            -- should not be found
    ('Coke, water23, 7up')              -- should not be found
    ;
SELECT * from drinkslist WHERE list||',' LIKE '%'||'water'||',%' OR list||',' LIKE 'water'||',%';

Resulting in :-

enter image description here

The above has been tested and it does work in room as per :-

All lists displays :-

enter image description here

Entering wAtER in the edit text and clicking the Selective button results in :-

enter image description here

Entering 7Up :-

enter image description here

and so on.

The query being :-

@Query("SELECT * FROM DrinkList WHERE list||',' LIKE '%'||:name||',%' OR list||',' LIKE :name||',%'")
List<DrinkList> getSelectiveDrinks(String name);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=155423&siteId=1