THis is my core Mysql query

select * from table_name where CONCAT(',', subscriptions, ',') like '%,4793,%'

and i want to apply below filter on magento 2 collection. where CONCAT(',', subscriptions, ',') like '%,4793,%'

  • I assume you have comma separated values stored in this field. You should try field in set Commented Sep 8, 2022 at 6:24

1 Answer 1


Use Zend_Db_Expr


$collection->getSelect()->where(new \Zend_Db_Expr("CONCAT(',', subscriptions, ',') LIKE (?)"), '%,4793,%');
  • No, I Have Data in table below format. {"tracks":{"album":"Megamix Chart Hits 2022","title":"Do It Better","artist":"Felix Jaehn Feat. Zoe Wees","bpm":"133","year":"2022","duration":130,"filename":"34 - Felix Jaehn Feat. Zoe Wees - Do It Better.mp3","filepath":"\/manageplaylist\/4833\/41866\/Megamix Chart Hits 2022\/34 - Felix Jaehn Feat. Zoe Wees - Do It Better.mp3"}} and i want collection where title equal to Commented Sep 29, 2022 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.