My team has stored array data as a string in MySQL like below
["1","2","22","11"]
How can we select data from the table where the column contains a certain branch number.
Example of table
sno | Name | Branch
1. | Tom. | ["1","2","22"]
2. | Tim. | ["1","2"]
Can you suggest a query to select all rows containing branch 2?
We tried using FIND_IN_SET()
but that is not working as the double quotes and square brackets are also a part of string.
CodePudding user response:
Use like:
select *
from mytable
where Branch like '%"2"%'