Query on Select2+multiple field
Posted: Thu Jan 26, 2023 11:02 am
I'm using select2 + multiple:
I'll give a simplified example:
- in object select tab: 1|Red|2|green|3|blue.
- field in the table -> 'color' varchar (255)
If in the object (select2 + multiple) I select (red and blue) in the 'color' field of table, ["1","3"] is stored, I think that's a json string!!.
At this point in a query I want to find (for example) all the records that have on this string (in field) the color set to "blue" ("3").
I try with json_extract and json_search statement but it returns me all the records or nothing.
In the real solution I'm actually developing i would like to use the field in an address book to insert some kind of tag and then use the contact based on the tags in specific parts of the database.
What is the mysql query to make this selection?!
I'll give a simplified example:
- in object select tab: 1|Red|2|green|3|blue.
- field in the table -> 'color' varchar (255)
If in the object (select2 + multiple) I select (red and blue) in the 'color' field of table, ["1","3"] is stored, I think that's a json string!!.
At this point in a query I want to find (for example) all the records that have on this string (in field) the color set to "blue" ("3").
I try with json_extract and json_search statement but it returns me all the records or nothing.
In the real solution I'm actually developing i would like to use the field in an address book to insert some kind of tag and then use the contact based on the tags in specific parts of the database.
What is the mysql query to make this selection?!