【MYSQL进阶挑战】筛选&排序

筛选(检索):

检索所有列:

select * from tb;

检索特定列

select 列名1,列名2,... from tb;

检索特定列并起别名

select  列1 as x,列2 as y,列3 as z from 

根据条件检索特定列

根据条件检索:
select  from tb where

检索列并去重 :

select distinct 列名 from tb;

where常见条件

逻辑判断:


= > >= < <=  not and or like in 

集合in:


where xx in(A,B,C....)

通配符(like):

扫描二维码关注公众号,回复: 13793314 查看本文章

%xxx:以xxx结尾
xxx%:以xxx开头
%xxx%:包含xxx
%xxx%yyy%:同时包含xxx和yyy,并且xxx在yyy之前

排序:

select from where
order by  xxx (desc);

where在order by之前

首先根据A排序,如果A相同,再根据B排序

order by A (DESC),
B(DESC);

字符串操作:

concat(a,b):连接ab
substring(a,start,length):截取a子串
upper(字符串):字符串大写

猜你喜欢

转载自blog.csdn.net/m0_52043808/article/details/124158841