How to use NOT FIND_IN_SET in Laravel 5.1?

2020-07-26 10:45发布

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?

1条回答
女痞
2楼-- · 2020-07-26 11:18

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')
查看更多
登录 后发表回答