色破飞机 发表于 2018-10-9 11:14:08

mysql 日志学习

创建一个表  

  
    create table test_student(
  
         id int auto_increment,
  
         firstName varchar(10) not null,
  
         lastName varchar(10) nont null,
  
         addtime date,
  
         primary key(id)
  

  
    )engine=innodb character set=utf8
  

  
插入语句
  

  
insert into test_student set firstName="zhang",lastName="san",addtime='2001-02-02';
  

  
insert into test_student set firstName="zhang",lastName="tian",addtime='2001-03-02';
  

  
insert into test_student set firstName="li",lastName="tian",addtime='2003-03-02';
  

  

  
查找 addtime 在等于 3月份的学生
  

  
select * from test_student where month(addtime)='03';
  

  
查找 addtime 等于 2001 年的学生
  

  
select * from test_student where year(addtime) ='2001';
  

  

  

  
//日期函数
  
// 返回日期date是星期几(1=星期天,2=星期一,……7=星期六,ODBC标准)
  
select dayofweek('2017-04-22') 返回7;
  

  

  
//日期函数博客
  

  
http://www.cnblogs.com/zeroone/archive/2010/05/05/1727659.html


页: [1]
查看完整版本: mysql 日志学习