Mysql常用指令(持续更新)

1.获取表中字段数:

select count(*) from information_schema.columns where table_schema='databaseName' and table_name='tableName' 

2.按每天0-23个时段查询数据:

SELECT B.hourTime as hourTime,
IFNULL(A.flowRebate,0) as flowRebate,
IFNULL(A.beforeRebateMoney,0) as beforeRebateMoney,
IFNULL(A.afterRebateMoney,0)as afterRebateMoney,
IFNULL(A.discountMoney,0) as discountMoney from
(
SELECT 
HOUR(t.ExitTime)as hourTime,
COUNT(*) as flowRebate,
SUM(t.PDiscountToll) as beforeRebateMoney,
SUM(t.TotalToll) as afterRebateMoney,
SUM(t.PDiscountToll - t.TotalToll) as discountMoney
FROM
(select ExitTime,PDiscountToll,TotalToll FROM aexit2019070150004 
where ExitDate = 20190701 and ExitStation = 150004
)  as t GROUP BY hourTime) as A
right JOIN (select DISTINCT HOUR(EXITTIME) as hourTime FROM aexit2019070150004 order by HOUR(EXITTIME)) as B
on A.hourTime = B.hourTime  
ORDER BY B.hourTime;

3.更新数据库配置

flush privileges;

4.设置数据库远程访问

use mysql;
update user set host = "%" where user = "root";
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值