mysql sql函式總結筆記

2022-06-23 04:39:13 字數 1093 閱讀 2776

date_format擷取時間字串

例子:select  date_format(c.loan_time,'%y-%m-%d') loan_time from customer c;

truncate函式用於擷取小數點後的位數  分別擷取字串後的012位。當不足兩位時不會補零

例子:select  truncate(r.pay_total_interest,0) from  repayment r;

sum函式用於求某一列的和  

max(min)函式用於求某一列的最大值(最小是)

count()統計一共有多少條資料

group by +分組字段,根據什麼分組

order by +排序字段,根據什麼排序

例子:select  sum(r.pay_total_interest) from  repayment r;

ifnull函式 語法ifnull(不為空的值(可能是空字串),為空的值)

in()的使用可以包含多個值

例子:where a in(a,b,c,d)先當與  where a =a or where a =b or where a = c or where a =d

MySql Sql語句總結

建表語句 create table class id int primary key,class char 255 name varchar 4000 hobby text int 和 integer 是一樣的,只是為了簡寫罷了,主鍵宣告直接跟在定義後面,char和varchar char是固定長度...

MySQL sql語句筆記

sql 插入insert into 表名 列名 values 值列表 關鍵字 可省略 insert into stu name,age,city values 18,1 更新 update 表名 set 列名 更新值 where 更新條件 update stu set name sdfsdf age...

Mysql sql常用操作總結

create database mybatis plus create database mybatis plus character set utf8 collate utf8 general ci 指定編碼格式utf8drop database ifexists mybatis plus alt...