Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use NOT FIND_IN_SET in Laravel 5.1?

As we use FIND_IN_SET to search in comma separated values in Laravel like:

->whereRaw('FIND_IN_SET(2,sent_mail_ids)')

But now I want to get those results which do not exist in comma separated values. To do this we use NOT FIND_IN_SET in MySQL, but how to use this in Laravel?

like image 869
Amrinder Singh Avatar asked Nov 21 '25 06:11

Amrinder Singh


1 Answers

whereRaw() allows you to add any arbitrary SQL code to your query - in order to reverse the constraint simply use the same query you'd use in raw SQL:

->whereRaw('NOT FIND_IN_SET(2,sent_mail_ids)')

or another variation of this constraint:

->whereRaw('FIND_IN_SET(2,sent_mail_ids) = 0')
like image 96
jedrzej.kurylo Avatar answered Nov 23 '25 19:11

jedrzej.kurylo