select concat('root','@','127.0.0.1');
select concat(user,'@',host) from mysql.user;
select concat_ws('@',user,host,) from mysql.user;
select user,group_concat(host) from mysql.user group by user;
select char_length('abcd');
select character_length('abcd');
select lower('ABCD');
select upper('abcd');
select trim(' abcd '); # 去除字符串两变空格
select bin(12);
select oct(12);
select hex(12),hex('abcd');
select unhex(hex('abcd')); #将转换成 16 进制返回原来的数字或字符串(十进制)
select abd(-123);
select 5/2,5 div 2;
select truncate(1.534143,2),truncate(-1.51234,2);
select pi();
select sqrt(2);
create table t2(
id int primary key auto_increment,
user varchar(32) not null,
pwd varchar(512) default null
) engine = innodb charset = utf8mb4;
insert into t2(user,pwd) value ('wyj',hex(aes_encrypt('字符串加密','key'))); hex 函数将其强转为 16 进制的字符串
select user,aes_decrypt(unhex(pwd),'key') as pwd from 42;
select now();
select current_time();
select current_date();
select unix_timestamp();
select dayofmonth(now());
select dayofyear(mow());
select year(now());
select hour(now());
select day(now());
select minute(now());
select monthname(now());
select quarter(now());
select last_day(now());
select dayname(now());
select week(now());
select weekday(now());
select weekofyear(now());