mysql小技巧

//增加对应的秒数
select
end_time+ interval 10 second from student;

 当我们需要在定时计划中检测时间,下面的方法就有用了,直接上sql语句,一看便知

//判断当前日天的天数
select
*from credit where DAY(now())=27;



//判断当前日天的月份
select *from credit where Month(now())=1;


//判断当前日天的年份
select *from credit where year(now())=1;



//判断当前日天的时间
select *from credit
where time(now())='15:16:27';

事件计划

查看事件计划是否开启
SHOW VARIABLES LIKE 'event_scheduler'
开启event_scheduler sql指令:
SET GLOBAL event_scheduler = ON; 关闭event_scheduler指令: SET GLOBAL event_scheduler = OFF;

导入文本文件中的数据

load data local infile "a.txt" into table user

 临时表

CREATE TEMPORARY TABLE tmp_table(
    SELECT
        id,
        name
    FROM
        tb_user
);

 使用group_concat将行转列

//根据分组将所有的记录组合到同一个字段中
select
id,name,cource group_concat(a.cource,":",a.score)as score from ( select id, distinct name,cource,score from table
group by name )a
原文地址:https://www.cnblogs.com/ives/p/6589598.html