select current_date();
select current_time();
select current_timestamp();
select date_add('2017-10-28', interval 10 day);
select date_sub('2017-10-1', interval 2 day);
select datediff('2017-10-10', '2016-9-1');
create table tmp(
id int primary key auto_increment,
birthday date
);
mysql> create table msg (
id int primary key auto_increment,
content varchar(30) not null,
sendtime datetime
);
select content,date(sendtime) from msg;
select * from msg where date_add(sendtime, interval 2 minute) > now()
select charset(ename) from EMP;
select concat(name, '的语文是',chinese,'分,数学是',math,'分') as '分数' from
student;
select length(name), name from student;
注意:length函数返回字符串长度,以字节为单位。如果是多字节字符则计算多个字节数;如果是单字节字符则算作一个字节。比如:字母,数字算作一个字节,中文表示多个字节数(与字符集编码有关)
select replace(ename, 'S', '上海') ,ename from EMP;
select substring(ename, 2, 2), ename from EMP;
select concat(lcase(substring(ename, 1, 1)),substring(ename,2)) from EMP;
select abs(-100.2);
select ceiling(23.04);
select floor(23.7);
select format(12.3456, 2);
select rand();
select user();
select md5('admin')
select database();
select password('root');
select ifnull('abc', '123');
select ifnull(null, '123');