DQL(Data Query Language)

一些关键字

起别名 as
去重复 distinct
条件查询 where
模糊查询:
(like +’%_s’)
between and
in
isnull / is not null
排序: order by

常见函数

1.单行函数

(1)字符函数
length(str) ,  concat(str.str..), 
upper(str), lower(str) ,
 substr(str,int pos) ,substr(str, pos , len)
  instr (str, substr)
trim("a"  from "aabbaa")  or trim("  asd  ")
lpad(str1被填入,int n , str填入)    rpad()     
replace(str,str1,str2)
(2)数学函数
round(float,int length)
ceil(int n )  .  floor(int n)
TRUNCATE(float N,INT I )    , TRUNCATE(1.123123,3 ) 
(3)日期函数
now();     curDate();  curTime();
Year(now());   Year('1998-1-1') ;
Month()  MonthName();
str_to_datae('9-13-1999',  '%m-%d-%Y')
date_format(now(),'%Y-%m-%d')


%Y:年(四位)    %y 年(2位)  %m 月(01- 12) %c 月(1-12)
%d  日 , %H :小时(24) ,%h 小时:(12)  , %o 分钟  , %s  秒
(4)其他函数
Version() ;  DataBase() , User()
(5) if 和case
if(条件,ture返回值,false返回值)
case 分为有参数和无参数
1.
	CASE input_expression
    WHEN when_expression THEN result_expression
    ELSE else_result_expression
    END
2.
CASE    
WHEN Boolean_expression THEN result_expression
WHEN Boolean_expression THEN result_expression
ELSE else_result_expression
    END

2.分组函数

sum(),avg() , max(), min() ,count()

查询

select xx,xx
from ()
left/right/full (outer) join ---- on(条件)
where 。。。
group by ()
having ()
order by ()
limint offset,size

子查询

select 搭配 (标量)
where/having (标量 = < > <> 等)
(列 in/not in , any/some , all)
(行 (A,B)=(select … ))
from 搭配 (表)
exists 搭配 (表) 返回一个bool 值

Union 、 Union ALL

要求: 1.对其 2.个数相等

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值