SQL学习——查询基础
来源:互联网 发布:知党规 行敬畏 编辑:程序博客网 时间:2024/04/30 08:04
查询基础:(关键词:select)
简单查询:
1:查询表的全部行和列
例1:select user_qq,user_name,user_sex from users;
例2:select * from users;
2:查询表的部分列
例:select user_qq from users;
3:使用别名
例:select user_qq [as] '玩家QQ' ,user_name [as] '玩家姓名' from users;
4:去除结果中的重复行
例:select distinct user_qq from scores;
5:指定显示范围
例:select * from users limit 2,3; (代表显示第3,4,5条数据)
select * from users limit 3; (代表显示第1,2,3条数据)
条件查询:
select 列名 from 表名 where 表达式
例:select * from users where user_qq='1234';
<> 不等于 and 与 or 或 not 非
模糊查询:(关键词:between and)
例:select * from scores where score between 2500 and 3000;
between and 中前面的数比后面的数小
not betwween and 表示不在该范围
通配符:
例:select * from users where user_name like '孙%'
%匹配任意一个或多个字符
not like
查询空值:
例:select * from users where user_birthday is null;
is not null
对查询结果排序:
select 列名 from 表名 where gno=1 order by 列名 [asc|desc] (asc为升序(默认),desc为降序)
多列排序:
select * from scores order by gno asc,score desc; (先排gno再基于gno基础上排score)
- SQL学习——查询基础
- SQL基础1——select查询
- SQL 基础6—— 子查询
- SQL命令学习——选择查询
- SQL基础5——多表查询
- SQL基础5——多表查询
- SQL语言——基础语言:查询、增、删、改
- 黑马程序员—SQL基础的学习
- SQL查询语句基础
- 基础查询sql
- SQL查询(一)基础
- SQL 基础-->SELECT 查询
- SQL 基础--> 子查询
- T-SQL查询基础
- sql 基础查询操作
- SQL 基础-->SELECT 查询
- sql基础查询
- SQL 基础-->SELECT 查询
- 学习Cortex-M:结构体 vs 分散变量
- kruskal
- java中实现同步的两种方式:syschronized和lock的区别和联系
- 工作中碰到的那些坑(二)-安卓混合开发webview打开链接出错
- 同城交友软件“快啵”开发总结----自定义Toast
- SQL学习——查询基础
- ORACLE的redo文件在不同机器上存储是否使用big-endian还是little-endian的问题
- 单片机程序下载,LED灯
- ImageLoader的各种格式DisplayImageOptions 的设置
- matlab ubuntu linux 出现 libGL error
- 适配android 7的自定义相机的预览及拍照
- 238. Product of Array Except Self
- Laravel学习:路由、视图、控制器工作流程(2)
- integer综合分析