SELECT SUBSTRING(‘abcdefg‘,2,5)
len(string)
--查询2010前入学入学ID select user from cf_log where substr(user,0,4)<2010 order by user ASC limit 0,10;
select count(*) from cf_user;
select count(user),user,pwd,name from cf_user group by user having count(user)>1;
insert into cf_grade1 select * from cf_grade where user=‘‘ order by term;
insert into cf_user(user,pwd,name,degree,dept,major,class,year) select distinct user,pwd,name,degree,dept,major,class,year from cf_log;
insert into ims_goods_3(model,name,price) select model,name,price from ims_goods_5 order by model;
delete from 表 where ID not in (select max(ID) from 表 group by 重复列);
DAYOFWEEK() 星期天:1,星期一:2…………
--查询星期天的记录 select * from d where DAYOFWEEK(FROM_UNIXTIME(time))=1;
select localtime(); select now(); --current_timestamp(),效果一样
select curdate();--2015-09-06
sysdate()
set @dt = now(); select dayofweek(@dt); -- 1 select dayofmonth(@dt); -- 6 select dayofyear(@dt); -- 249 返回当前年份第多少天
select last_day(now()); -- 2015-09-30
两个日期时间差[返回int型]:
若第一个参数小于第二个参数返回结果为负数
select datediff(now(),‘2015-08-28‘);
原文:http://my.oschina.net/rain21/blog/501837