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索引