mysql的in关键字使查询出来的数据与in的条件一样排序 select * from table where id IN (3,6,9,1,2,5,8,7) order by field(id,3,6,9,1,2,5,8,7); field() 函数 : 是将查询的结果集按照指定顺序排序。 格式: FIELD(str,str1,str2,str3,...)
基本时间 now(), current_timestamp(); -- 当前日期时间 current_date(); -- 当前日期 current_time(); -- 当前时间 date('yyyy-mm-dd hh:ii:ss'); -- 获取日期部分 time('yyyy-mm-dd hh:ii:ss'); -- 获取时间部分 date_format('yyyy-mm-dd hh:ii:ss', '%d %y %a %d %m %b %j'); -- 格式化时间 unix_timestamp(); -- 获得unix时间戳 from_unixtime(); -- 从时间戳获得时间 1. 当前日期 select DATE_SUB(curdate(),INTERVAL 0 DAY) ; 2. 明天日期 select DATE_SUB(curdate(),INTERVAL -1 DAY) ; 3. 昨天日期 select adddate(now(),-1) select date_sub(now(),interval 1 day) 4. 前一个小时时间 select date_.......