≡
  • 网络编程
  • 数据库
  • CMS技巧
  • 软件编程
  • PHP笔记
  • JavaScript
  • MySQL
位置:首页 > 数据库 > MySQL

MySQL笔记之基本查询的应用分析

人气:384 时间:2020-07-09

这篇文章主要为大家详细介绍了MySQL笔记之基本查询的应用分析,具有一定的参考价值,可以用来参考一下。

感兴趣的小伙伴,下面一起跟随四海网的小编小韵来看看吧!

参考表:student



多字段查询

代码如下:


mysql> select id,name,birth from student;


所有字段查询

代码如下:


mysql> select * from student;


where指定查询

代码如下:


mysql> select * from student where id=901;
mysql> select * from student where id>=904;
mysql> select name from student where department='计算机系';


in指定集合查询

代码如下:


mysql> select * from student where birth in(1988,1990);
mysql> select * from student where id in(903,906);

not in非范围查询

代码如下:


mysql> select * from student where birth not in(1990,1998);


between and指定范围查询

代码如下:


mysql> select * from student where birth between 1986 and 1988;


not between and不在指定范围的查询

代码如下:


mysql> select * from student where id not between 904 and 906;


like字符串匹配查询

代码如下:


mysql> select * from student where name like '_三';
mysql> select * from student where name like '张三';
mysql> select * from student where name like '张%';


not like不匹配查询

代码如下:


mysql> select * from student where name not like '张%';


null查询

代码如下:


mysql> select * from student where address is null;


and多条件查询

代码如下:


mysql> select * from student where name like '张%' and birth>1985;
mysql> select * from student where name like '张%' and birth>1985 and id like '%3';


or多条件查询

代码如下:


mysql> select * from student where id=905 or birth=1988;
mysql> select * from student where id=905 or birth=1988 or sex='女';

 

distinct查询结果不重复

代码如下:


mysql> select distinct sex from student;
mysql> select distinct department from student;


order by查询结果排序

代码如下:


mysql> select * from student order by birth;
mysql> select * from student order by birth asc;
mysql> select * from student order by birth desc;


group by分组查询

代码如下:


mysql> select sex,group_concat(name) from student group by sex;
mysql> select sex,count(name) from student group by sex;


正则表达式查询

代码如下:


mysql> select * from student where birth regexp '1988|1990';


limit限制查询结果数量

代码如下:


mysql> select * from student limit 2;
mysql> select * from student limit 1,3;
 

 

本文来自:http://www.q1010.com/177/9958-0.html

注:关于MySQL笔记之基本查询的应用分析的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。

关键词:MYSQL

您可能感兴趣的文章

  • MySQL笔记之别名的使用
  • linux Xtrabackup安装及使用方法
  • MySQL笔记之触发器的应用
  • Java连接MySQL的详细介绍
  • MySQL笔记之数学函数分析
  • MySQL笔记之数据备份与还原的使用分析
  • 拥有5星评级数据库表结构 如何才能更高效的使用?
  • MySQL笔记之系统信息函数分析
  • MySQL笔记之字符串函数的应用
  • PHP之MySQL常用SQL语句示例的深入分析
上一篇:JDBC数据库的使用操作总结
下一篇:MySQL笔记之字符串函数的应用
热门文章
  • mysql 修改character_set_server为utf-8的简单示例
  • 解决MySQL丢失文件localhost.localdomain.pid、mysql.sock的示例
  • MySQL 数据类型binary和varbinary的简单示例
  • MySQL:reading initial communication packet问题解决方法
  • MySql 表类型MYISAM、InnoDB区别
  • bash: mysql: command not found 的解决方法
  • MYSQL默认用户名ROOT修改方法
  • MySQL 常用命令菜鸟教程
  • MySQL 使用命令行新建用户并授予权限
  • MySql 数据库物理文件存放位置查看示例
  • 最新文章
    • MySQL查看死锁与解除死锁的简单示例
    • MySQL 慢查询的功能实例
    • MySQL查看死锁与去除死锁的简单示例
    • MySQL找出未提交事务的SQL的简单示例
    • MySQL锁阻塞的的简单示例
    • MySQL中的binary类型使用操作的示例
    • SQL优化教程之in与range查询的简单示例
    • MySQL 的 21 个规范、优化最佳实践!
    • MySQL 字符类型大小写敏感的简单示例
    • 解决mybatis-plus分页传入参数后sql where条件没有limit分页信息的问题

四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。