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
shiniv
V2EX  ›  MySQL

关于Mysql的按位与操作

  •  
  •   shiniv · Dec 27, 2013 · 14660 views
    This topic created in 4599 days ago, the information mentioned may be changed or developed.
    最近研究Discuz时发现了一段sql语句,但是不知道具体意思
    语句大概是这样的 select * from pre_table where (tag & 12) = 12
    语句执行后tag栏有12,13,14,28,30
    不太理解(tag & 12) = 12 具体是怎么算的。。
    求大神指导...
    Supplement 1  ·  Dec 27, 2013
    @wingoo @luckywulin 非常感谢你们的回答,找到答案了

    3&2 = 1 (3 = 1 + 2, 由 1和2组成 ,所以判断3&2 = 1 )
    3&4 = 0 (3 没有由 4组成,所以判断3&4 = 0)
    2 replies    1970-01-01 08:00:00 +08:00
    luckywulin
        1
    luckywulin  
       Dec 27, 2013   ❤️ 1
    不知道需求是什么,如果tag是单字节的话,表示tag的第5,6位为1吧,是不是通过位来操作逻辑的。
    wingoo
        2
    wingoo  
       Dec 27, 2013   ❤️ 1
    搜索下与运算
    数据库中用到一般是省空间, 每一位都可以做标记, 并且很方便计算
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2715 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 11:44 · PVG 19:44 · LAX 04:44 · JFK 07:44
    ♥ Do have faith in what you're doing.