首页 PHP小记正文

mysql常用查询语句记录

刘伟 PHP小记 2019-12-14 1201 8

mysql查询语句

版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。

评论

精彩评论
  • 2019-12-14 13:28:17

    select id,
    count(case when type = 1 then id end) as 酒店,
    count(case when type = 2 then id end) as 保洁员,
    count(id) as total
    from 表名;

  • 2020-01-06 11:48:33

    select id, hname, order_state, from_unixtime(create_time, '%Y-%m-%d'), count(*) as sum
    from `order`
    where hid = '765ED6C5_DDDE_3564_E620_4DF69B00'
    and order_state = 40
    group by create_time;
    统计每天的订单量

  • 2020-01-16 10:43:00

    mysql关联查询 筛选字段 示例
    select o.real_amount,o.hname,os.cname,os.cphone,o.order_state from
    order_status as os
    inner join `order` as o
    on os.order_id = o.id
    where cid='BF9FA27D_8D79_ADE3_5F9F_7F4325BF'
    and o.order_state=40;

  • 2020-01-16 11:45:16

    -- select * from order_status where cid='BF9FA27D_8D79_ADE3_5F9F_7F4325BF' and order_state='40'
    -- left join order as o;
    select
    o.real_amount as '收入',
    o.hname as '酒店名',
    os.cname as '保洁姓名',
    os.cphone as '保洁电话',
    o.order_state as '订单状态',
    from_unixtime(o.create_time) as '创建时间'
    from
    order_status as os
    inner join `order` as o
    on os.order_id = o.id
    where cid='BF9FA27D_8D79_ADE3_5F9F_7F4325BF'
    and o.order_state=40;

  • 2020-02-03 12:09:13

    排好序的快速查找数据结构

  • 2020-03-26 14:17:42

    添加字段到某个字段之后
    alter table hotel_info add column area_code varchar(10) not null comment"酒店所在区/县code码" default '' after city_code;

  • 2020-05-13 11:19:50

    mysql 在某个字段之前或者之后添加字段
    alter table account Add column is_admin TINYINT not null default 0 AFTER hotel_id

  • 2020-05-19 17:52:15

    如果是本地进程,cat到对应目录,kill调再删除对应程序,如果是网络攻击,加个防火墙或安全组策略阻断