V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
acking
V2EX  ›  问与答

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

  •  
  •   acking · Aug 24, 2016 · 1398 views
    This topic created in 3533 days ago, the information mentioned may be changed or developed.
    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 的数据,这条数据不出现,请问该怎么操作?
    Supplement 1  ·  Aug 24, 2016
    not find_in_set('d',class) 和 !find_in_set('d',class) 返回的结果一样
    3 replies    2016-08-24 13:38:13 +08:00
    ijustdo
        1
    ijustdo  
       Aug 24, 2016   ❤️ 1
    不明白 你是不是要找 没有 d 的数据
    SELECT * FROM table WHERE `name` = 'zhang' AND not find_in_set('d',class)
    sherlocktheplant
        2
    sherlocktheplant  
       Aug 24, 2016
    楼主的语言表达能力简直让人着急 楼主的意思是用这条 SQL 查不出来他想要的数据
    sherlocktheplant
        3
    sherlocktheplant  
       Aug 24, 2016
    检查下 class 字段的分隔符是否是 英文的逗号“,” 如果是中文的逗号”,“匹配会失败
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3560 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 12:00 · PVG 20:00 · LAX 05:00 · JFK 08:00
    ♥ Do have faith in what you're doing.