V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
funky
V2EX  ›  MySQL

mysql contains 问题

  •  
  •   funky · May 18, 2015 · 6950 views
    This topic created in 3997 days ago, the information mentioned may be changed or developed.
    有个问题,表里某条记录是 ArraySize ---><code>2,3,4,58,11,12,13</code>这样的。
    select * from XXX where ArraySize like '%1%' 这样并不能查询出包含1的记录。如果用contains
    select * from XXX where contains(ArraySize,'1') 这样查询带1的记录时候返回的是空,问题出在哪呢?
    9 replies    2015-05-18 15:52:00 +08:00
    msg7086
        1
    msg7086  
       May 18, 2015
    上个表结构很难吗
    Septembers
        2
    Septembers  
       May 18, 2015
    看了下文档没有string functions里没contains函数
    唯一相关的是: https://dev.mysql.com/doc/refman/5.6/en/spatial-relation-functions-mbr.html#function_contains
    see https://dev.mysql.com/doc/refman/5.6/en/string-functions.html

    @msg7086 我发现V2好多MySQL的问题都是不啃文档加想当然
    funky
        3
    funky  
    OP
       May 18, 2015
    @Septembers 额。我之前看了mysql function index 中关于contains的说法。但是我在测试的时候发现并不是那样。难道我的姿势错了?
    MarkYao
        4
    MarkYao  
       May 18, 2015
    @funky 使用mysql 函数FIND_IN_SET(ArraySize,'1') mysql内部字段切分特殊token变成集合然后再查找
    funky
        5
    funky  
    OP
       May 18, 2015
    @MarkYao 谢谢
    msg7086
        6
    msg7086  
       May 18, 2015
    @Septembers 有时候真想让他们读读提问的智慧。但是再一想,这关我啥事呢……
    Septembers
        7
    Septembers  
       May 18, 2015
    @funky 老老实实啃官方手册靠谱
    Septembers
        8
    Septembers  
       May 18, 2015
    @msg7086 问个无关的话题你已经 忽略多少主题 了?我差不多200
    msg7086
        9
    msg7086  
       May 18, 2015
    @Septembers
    屏蔽人数 2
    忽略节点 0
    忽略主题 0

    忽略主题要靠naonei_filter(),看着不对劲的主题只要没人回复,没几天就自己沉了,也不需要手动忽略。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3739 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 04:30 · PVG 12:30 · LAX 21:30 · JFK 00:30
    ♥ Do have faith in what you're doing.