MySQL数据库查询操作
来源:互联网 发布:北京和隆优化 编辑:程序博客网 时间:2024/05/16 18:25
1、选择特定的字段
select id,name,password from user; //查询特定字段,id,name,password顺序可以随意
select*from user; //查询所有字段
2、字段别名:用空格或as
select id '学号',name '姓名',password '密码' from user;
select id as '学号',name as '姓名',password as '密码' from user;
3、distinct关键字,去除重复的值(多字段时需要所有字段同时相同才会认为是重复)
select distinct age from user;
4、使用where条件查询
5、查询空值null
select*from user where name is null;
select*from user where name is not null;
6、between and用法
select*from user where id between 3 and 5;
7、in 的用法
select*from where id in(1,3,5);
8、like关键字用法,模糊查询,text类型不能用
select*from user where name like '%s%';
select*from user where name like '%s%'or name like '%b%';
//查询name里面包含字母s的数据,%表示任意多个字符
也可以用正则表达式:(不建议用)
select*from user where name regexp '.*s.*';
select*from user where name regexp '(.*s.*)|(.*5.*)';//包含s或5
9、使用order by对查询结果排序
select*from user order by 字段名 desc; //desc表示降序,默认升序(asc)
10、使用limit限定输出个数(分页实现)
select*from user order by id limit 0,2;
select*from user order by id limit 5; //相当于0,5,从0开始取5个
- MySQL数据库查询操作
- mysql数据库查询操作类
- MySQL数据库通过JDBC操作,简单查询
- C++链接MySQL数据库查询操作
- mysql+C#实战三:数据库查询操作;
- mysql 初级操作-查询数据库时间
- mysql数据库的查询(select)操作
- mysql数据库基本查询语句操作
- MySQL+Java——数据库查询操作
- 【java 操作mysql】java连接mysql数据库并查询数据
- C# 操作 MySQL 数据库(连接,查询,插入)
- Python操作MySQL数据库--插入、更新、查询(二)
- MySQL 数据库操作,将查询结果插入新表
- MySql数据库的基本操作-表的建立/查询
- 【web学习之Mysql】数据库----->查询操作<------大全
- python SQLAlchemy操作mysql数据库:插入,查询,删除,更新
- Php中使用PDO操作MySQL数据库(查询 更新 删除)
- 用代码操作mysql数据库(添加和查询数据功能)
- MyBatis:Parameter Maps collection does not contain value for 的问题解决
- Volecity模板引擎学习笔记<一>
- (java并发)ScheduledThreadPoolExcutor
- CString转int _ttoi() _tcstoul() Format ASSERT() Format的用法
- Leetcode First Missing Positive
- MySQL数据库查询操作
- 数据库事务
- Struts2学习笔记——Struts2与Spring整合
- NOIP 2013 积木大赛 贪心
- 简单的Gson转换json数据
- Redis开源代码读书笔记六(sds模块)
- java集合类图
- 数据库性能优化
- 多线程介绍