-2

i have a table called product. The values in table is as follows(given one row as an example).

productid     name                   group_id          slug
222          testproduct           22,24,26,28        testproduct

and so on. for a search functionality am getting the module id as 24 i need to get the product details where group_id = 24; my code is as follows

$idd = 24;
$products->where('group_id', $idd); 

i didnt get the expected answer since the group_id is as multiple elements in the field. i need to get the product details of productid 222 where group_id is 24. How can i make the query for that.Thank you in advance.

GMB
  • 216,147
  • 25
  • 84
  • 135
vinny K.B
  • 3
  • 2

1 Answers1

0

In MySQL, you can use find_in_set() to search for a value in a CSV list:

where find_in_set(?, group_id)

The question mark represents the value to search for.

You should be able to adapt this piece of code so you can run it from your ORM.

GMB
  • 216,147
  • 25
  • 84
  • 135