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;

     

     

  • 相关阅读:
    Ubuntu下ATI显卡风扇转速调节脚本
    App_GlobalResources和LocalResources文件夹区别
    ubuntu下添加开机启动项
    UBUNTU安装PHP
    ubuntu apache2配置
    在ubuntu 上安装半透明玻璃窗口
    ASP.NET 页面:在此页面动态调用用户控件(.ASCX)
    Ubuntu 安装 LAMP 主机之后运行出现乱码
    Ubuntu下安装LMAP—菜鸟版
    Ubuntu 10.04风扇声音太大
  • 原文地址:https://www.cnblogs.com/bandbandme/p/10969590.html
Copyright © 2011-2022 走看看