-1

I have a field pattern (is string).

examples:

id | pattern
 1 | car;cat;dog       -> words car cat do
 2 | apple;nocar;carno -> words apple nocar carno 

So, now, I would like to select all items where pattern contains full word 'car'.

Expected result is:

id | pattern
 1 | car;cat;dog

because there is car - it should skip words like nocar and carno

Thank you for any help.

Strawberry
  • 33,750
  • 13
  • 40
  • 57
  • ```WHERE FIND_IN_SET('car', REPLACE(`table`.`pattern`, ';', ','))```. The "words" itself must NOT contain a comma. – Akina Nov 18 '20 at 08:20

1 Answers1

0

Could a simple LIKE solve it?

SELECT
    *
FROM
    TABLE
WHERE
    pattern LIKE 'car;%'
    OR pattern LIKE '%;car;%'
    OR pattern LIKE '%;car';
itainathaniel
  • 655
  • 1
  • 6
  • 12