V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
acking
V2EX  ›  问与答

mysql 中 find_in_set('b','a,b,c') 可以输出 1 ,如果 find_in_set('d','a,b,c') 输出 0 的话

  •  
  •   acking · 2016-08-24 11:56:44 +08:00 · 1071 次点击
    这是一个创建于 2809 天前的主题,其中的信息可能已经有所发展或是发生改变。
    mysql 中 find_in_set('b','a,b,c') 可以输出 1 ,如果 find_in_set('d','a,b,c') 输出 0 的话,
    $sql = "SELECT * FROM table WHERE `name` = 'zhang' AND find_in_set('d',class)";
    我要获得是的字段 class 有 d 的数据,这条数据不出现,请问该怎么操作?
    第 1 条附言  ·  2016-08-24 13:31:43 +08:00
    not find_in_set('d',class) 和 !find_in_set('d',class) 返回的结果一样
    3 条回复    2016-08-24 13:38:13 +08:00
    ijustdo
        1
    ijustdo  
       2016-08-24 12:50:17 +08:00   ❤️ 1
    不明白 你是不是要找 没有 d 的数据
    SELECT * FROM table WHERE `name` = 'zhang' AND not find_in_set('d',class)
    sherlocktheplant
        2
    sherlocktheplant  
       2016-08-24 13:34:55 +08:00
    楼主的语言表达能力简直让人着急 楼主的意思是用这条 SQL 查不出来他想要的数据
    sherlocktheplant
        3
    sherlocktheplant  
       2016-08-24 13:38:13 +08:00
    检查下 class 字段的分隔符是否是 英文的逗号“,” 如果是中文的逗号”,“匹配会失败
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   805 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 499ms · UTC 22:09 · PVG 06:09 · LAX 15:09 · JFK 18:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.