select length('john');
select concat('I',' ','like',' ','mysql');
select upper('mysql'); select lower('MySQL');
#从第几个字符开始截取,注意:索引从1开始 select substr('I like MySQL',8); #从第几个字符开始截取,截取几个字符 select substr('I like MySQL',8,2);
select instr('I like MySQL','MySQL');
select trim(' My SQL ');
select lpad('MySQL',8,'*');
select rpad('MySQL',8,'*');
select replace('aabb','bb','cc');
select round(1.4); #小数点后保留几位 select round(1.567,2);
select ceil(1.2);
select floor(1.2);
select truncate(1.61,2);
select mod(10,3);
select now();
select curdate();
select curtime();
select year('2020-10-10'); select month('2020-10-10');
select str_to_date('2020年10月12','%Y年%m月%d');
select date_format('2020/10/12','%Y-%m-%d');
流程控制结构分为顺序结构、分支结构、循环结构sql
从上往下依次执行函数
从两条或多条分支选择一条执行oop
#语法 if(表达式1,表达式2,表达式3) 表达式1成立,则执行表达式2,不然执行表达式3 select if(6<3,'小于','大于');
#语法 case 表达式|变量|字段 when 要判断的值 then 结果 when 要判断的值 then 结果 ... else result end
#语法 case when 要判断的条件 then 结果 when 要判断的条件 then 结果 ... else result end
#语法 if 条件1 then 语句1; elseif 条件2 then 语句2; else 语句; end if;
在知足必定的条件下,重复执行一段代码code
循环控制orm
【标签:】while 循环条件 do 循环体 end while 【标签】;
【标签:】loop 循环体 end loop 【标签】;
【标签:】 repeat 循环体 until 捷顺循环的条件 end repeat 【标签】;
select sum(salary) from employees;
select avg(salary) from employees;
select max(salary) from employees;
select min(salary) from employees;
select count(id) from users;
因为自己的博客百度没有收录,博客地址http://zhhll.icu索引