0

I have a table with lots of features, but I used features as just one column.

tbl_shop

id     |     name        |    feature

I used php implode to save the data to feature, and it will show like this

id     |     name        |    feature
1      |    shop_1       |   wifi,smarttv,cr

When I use LIKE to search for the data I can actually get the shop properly if I just search for one feature like wifi

the thing is if i tried to search for wifi,smarttv or smarttv,cr there is no problem, but when I tried to search wifi,cr that time it would not find the shop, is there any way of searching data like this in MySQL ?

1
  • Fix your data model so you have a shop/features table with one row per shop and feature. Commented Mar 6, 2020 at 3:17

1 Answer 1

1

You can insert a % in between your shops (or partial shops)

select * from table where feature like '%wifi%cr%';
Sign up to request clarification or add additional context in comments.

1 Comment

now its working, never knew about this one thank you

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.