与 MySQL FIND_IN_SET 相反
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6988652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Opposite of MySQL FIND_IN_SET
提问by phirschybar
How can I do the equivalent of:
我怎样才能做相当于:
!FIND_IN_SET('needle', haystack)
回答by Paul
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')
FIND_IN_SET
如果找到则返回匹配项的索引,如果未找到则返回 0。由于 0 是 FALSE,因此您可以使用NOT FIND_IN_SET('needle', 'haystack')
回答by Pelshoff
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set
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.
FIND_IN_SET('needle', haystack) = 0
应该做的伎俩。
回答by Guillaume Renoult
It seems like it doesn't work if the field is NULL and therefore doesn't contain the value.
如果该字段为 NULL 并且因此不包含该值,则它似乎不起作用。
A workaround:
解决方法:
WHERE id NOT IN (SELECT id FROM table WHERE FIND_IN_SET(needle,haystack))
Hope it'll help!
希望它会有所帮助!
回答by user3273891
SELECT id FROM table where !FIND_IN_SET(needle,haystack).......
Its working for me...
它对我有用...