Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opposite of MySQL FIND_IN_SET

How can I do the equivalent of:

!FIND_IN_SET('needle', haystack)
like image 575
phirschybar Avatar asked Aug 08 '11 21:08

phirschybar


Video Answer


2 Answers

FIND_IN_SET returns the index of the match if it is found, and returns 0 if it is not found. Since 0 is FALSE you can just use NOT FIND_IN_SET('needle', 'haystack')

like image 107
Paul Avatar answered Sep 28 '22 08:09

Paul


http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set

FIND_IN_SET('needle', haystack) = 0 should do the trick.

like image 20
Pelshoff Avatar answered Sep 28 '22 09:09

Pelshoff