mysql 登录 匹配,mysql的高级匹配条件

1.模糊查询 like

_ 表示1一个字符

% 表示0-n个字符

mysql> select name from user where name like '_';

mysql> select name from user where name like '%a%';

mysql> select name from user where name like '%_%';

2.正则表达式 regexp

正则:^ $ [] * |

mysql> select name from user where name regexp '^a|t$';

mysql> select name from user where regexp '^[abc]';

mysql> select name from user where name regexp '^..$';

3.计算

/ % ()

mysql> select name,uid from user where uid%2=0;

mysql> update user set uid=uid+1 where id<=5;

mysql> select name,uid from user where id <=5;

mysql> update user set uid=uid-1 where id<=5;

mysql> select name,2020-age csnf from user where name="root";

4.查询结果在处理

avg 统计字段平均值

sum 统计字段之和

min 统计字段最小值

max 统计字段最大值

count 统计字段值的个数

mysql> select count(*) from user;

mysql> select count(name) from user;

mysql> select avg(uid) from user;

mysql> select min(gid) from user;

5.排序

order by 字段名

asc 升序 desc 降序

mysql> select name,uid from user where id<=15 order by uid;

mysql> select name,uid from user where id<=15 order by uid desc;

6.查询分组

mysql> select uid from user group by uid;

7.查询过滤 having

mysql> select name from user where uid > 5;

mysql> select name from user where uid > 5 having name="myslq";

8.限制查询行数 limit

mysql> select name,uid from user limit 3;

mysql> name,uid gid from user limit 3 3;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值