chan

朝生暮死不足笑 但悲百年不足道

【MySQL】通配符


select * from info,depart where info.id > 10; –适合在查多张表连表查询时指定时哪个表的id
select * from info where id > 10; –单表查询时无需指定

通配符

%表示n个字符

_表示一个字符

__表示两个字符 –两个下划线

select * from info where name like "%沛%";
select * from info where name like "%沛";
select * from info where email like "%@live.com";
select * from info where name like "武%齐";
select * from info where name like "k%y";
select * from info where email like "wupeiqi%";


select * from info where email like "_@live.com";
select * from info where email like "_upeiqi@live.com";
select * from info where email like "__peiqi@live.com";
select * from info where email like "__peiqi_live.co_";

映射(就是指定列的意思)

desc 倒序

asc 顺序

SQL执行顺序

where

group by

having

order by

limit

select age,count(id) from info where id > 2 group by age having count(id) > 1 order by age desc limit 1;

评论
还没有评论
    发表评论 说点什么