标签:insert font student create ima datetime into 时间 倒数
CREATE TABLE `employees` ( `emp_no` int(11) NOT NULL, `birth_date` date NOT NULL, `first_name` varchar(14) NOT NULL, `last_name` varchar(16) NOT NULL, `gender` char(1) NOT NULL, `hire_date` date NOT NULL, 只有年月日 PRIMARY KEY (`emp_no`));
所以同一入职的或许有很多人,order by files asc limit 1 是错误的
最晚入职的时间是最大的
select * from employees where hire_date = (select max(hire_date) from employees );
--------------------------------------------------------------------
mysql的日期类型分析
create table student( id int, name char(6), born_year year, birth_date date, class_time time, reg_time datetime ); insert into student values (1,‘egon‘,now(),now(),now(),now()); insert into student values (2,‘alex‘,"1997","1997-12-12","12:12:12","2017-12-12 12:12:12");
CREATE TABLE `employees` ( `emp_no` int(11) NOT NULL, `birth_date` date NOT NULL, `first_name` varchar(14) NOT NULL, `last_name` varchar(16) NOT NULL, `gender` char(1) NOT NULL, `hire_date` date NOT NULL, PRIMARY KEY (`emp_no`));
select * from employees where hire_date = (select hire_date from employees order by hire_date desc limit 2,1 ); 注意limit 后面的 (n,m) n指索引 m是步长
标签:insert font student create ima datetime into 时间 倒数
原文地址:https://www.cnblogs.com/foremostxl/p/11197537.html