Home > Enterprise >  How do i search a string data (i.e. "12") from string array (i.e. ["12","13
How do i search a string data (i.e. "12") from string array (i.e. ["12","13

Time:09-13

I am trying to search data from my mysql table. Table field type is text. My fields and data like:

table data and fields

When I am trying to query like:

SELECT * FROM `packages` WHERE `assign_div` LIKE "%1%" AND `assign_dist` LIKE "%1%";

it brings up all other data like "10", "51", "21" and so on (cos i have used "%%").

How can i arrange my query that only brings the passed data or what will be the best way to convert those string array data and search?

CodePudding user response:

You need to add " to specify the accurate value

SELECT * FROM `packages` WHERE `assign_div` LIKE "%1%" AND `assign_dist` LIKE "%\"1\"%";
  • Related