zoukankan      html  css  js  c++  java
  • sql语句

    平时的数据库操作都是图形化界面完成了。然而有时候批量操作字段的时候还是不得不用到原生的sql语句。so这个就专门记录下自己使用过的又记不住的sql语句。没事看看拿起来当备忘录

      批量修改某个字段的数据

      update 表名 set 字段名=" " where 条件;

      update order set is_finish='2' where is_finish = '1'.   (别order表中is_finish=2的都改为1)

      时间查询:    

          ps:date为表中时间字段的字段名

      查询近七天的数据:

        select * from 表名 where datediff(now(), date) < 7;

      查询七天以外的数据:

        select * from 表名 where datediff(now(), date) > 7;

      查询本月的数据:

        select * from 表名 where date_format(date, "%Y%m") = date_format(Now(),"%Y%m");

      查询某个月的数据:

        select * from 表名 where date_format(date, "%Y%m") = date_format("2018-12-12","%Y%m");

       FROM_UNIXTIME(unix_timestamp,format)

       参数unix_timestamp  时间戳 可以用数据库里的存储时间数据的字段

       参数format  要转化的格式  比如“”%Y-%m-%d“”  这样格式化之后的时间就是 2017-11-30

        select update_time,from_unixtime(update_time,'%Y-%m-%d') as riqi FROM iot_manageruser;

      链表查询:

      select * 表一 as a left join 表二 as b on a.外键 = b.主键

      select * mangeruser as m left join company as c on m.company_id = c.id;

     
     
     
  • 相关阅读:
    一个JavaScript反射使用的例子
    JQuery中的each()的使用
    WebHome < Visualization < Virtual Test Facility
    UsageHdf < Amroc < Virtual Test Facility
    批量去除输出数据文件名前面的"output“
    官网EI数据库更新
    NASA CEA 安装指南
    FORTRAN学习网站
    Ubuntu下批量使用Tecplot的preplot命令对数据进行处理
    FORTRAN和C语言数组循环顺序
  • 原文地址:https://www.cnblogs.com/qx1996liu/p/14014569.html
Copyright © 2011-2022 走看看