SQL语句之增删查改、多表查询,模糊查询

现有数据库test,有两张表account、account_name,如下乃查询语句:

use test;
/*查询前3条数据*/
/*select * from account order by id asc limit 0,3;*/

/*查询后3条数据*/
/*select * from account order by id desc limit 0,3;*/

/*查询结果不显示重复记录条数,如果username重复则显示第一条记录*/
/*select distinct username from account;*/

/*查询不重复记录*/
/*select id,username,password from account group by username*/

/*查询记录条数*/
/*select count(*) from account where id>4*/

/*交叉连接*/
/*select account.id, account.username, account.password, account_name.name 
from account cross join account_name where account.id=account_name.id;*/

/*% 模糊查询某列是否含有对应字符,查询password含有15的密码*/
/*select * from account where password like '%15%';*/

/*_ 匹配单个任意字符,通常用来限制表达式的字符长度,三位密码,中间必须是5*/
/*select * from account where password like '_5_';*/

/*[] 中括号内为一个集合,选择其中任意一个与中括号外组成一个结果,将找出张三、李三、王三*/
/*select * from account_name where name like '[张李王]三';*/

/*[^] 表示不在括号内的单个字符与括号外组成一个查询结果*/
/*select * from  account_name where name like '[^王]三';*/


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值