zoukankan      html  css  js  c++  java
  • mysql 数据库查询和设计

    MySQL的FIND_IN_SET()函数

    NSERT INTO `test` VALUES (1, 'name', 'daodao,xiaohu,xiaoqin');
    INSERT INTO `test` VALUES (2, 'name2', 'xiaohu,daodao,xiaoqin');
    INSERT INTO `test` VALUES (3, 'name3', 'xiaoqin,daodao,xiaohu');
     
    test1:sql = select * from `test` where 'daodao' IN (`list`);
    得到结果空值.
    test2:sql = select * from `test` where FIND_IN_SET('daodao',`list`);
    得到三条数据。
     
    查询, 时间戳格式化为日期
    【 DATE_FORMAT(from_unixtime(dateline), '%Y-%m-%d %H:%i:%S') 】

      select from_unixtime(1560221981);

     

      | 2019-06-11 10:59:41       |

     

     

    . 对于BTREE这种Mysql默认的索引类型,具有普遍的适用性

     

    . 查找指定库中,哪些表含有特定字段

     

     SELECT DISTINCT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'extend' AND TABLE_SCHEMA='dbname';

     

     

     

     

    Json 格式查询

     

    select count(*) from user where JSON_EXTRACT(extend, '$.sex')=2;

     

     

  • 相关阅读:
    常见问题汇总
    python的正则表达式
    Python 程序读取外部文件、网页的编码与JSON格式的转化
    第三方仓库PyPI
    文件名称一定不要设置为某些模块名称,会引起冲突!
    迟来的博客
    FENLIQI
    fenye
    Notif
    phpv6_css
  • 原文地址:https://www.cnblogs.com/bandbandme/p/10969590.html
Copyright © 2011-2022 走看看