select进阶
2015-08-25 22:40
190 查看
(1)使用case来表达update
(2)排序——order by
默认为升序(ASC)排序,降序可在列名后面加“DESC”
按多列排序,中间用逗号隔开
(3)加总、平均、最大、最小、分组
SUM、AVG、MAX、MIN、group by
以上函数可以单独使用,也可以结合使用
(4)计数、独一无二
count、distinct
两者结合使用
(5)限制查询结果的数量——limit
例
两个参数
注:SQL是0开始
update my_table set new_column= case when column1=somevalue1 then newvalue1 when column2=somevalue2 then newvalue2 else newvalue3 end;
(2)排序——order by
默认为升序(ASC)排序,降序可在列名后面加“DESC”
按多列排序,中间用逗号隔开
(3)加总、平均、最大、最小、分组
SUM、AVG、MAX、MIN、group by
以上函数可以单独使用,也可以结合使用
(4)计数、独一无二
count、distinct
两者结合使用
select count(distinct sale_date) from cookie_sales;
(5)限制查询结果的数量——limit
例
limit 2为只输出两条结果
两个参数
limit 0,4,0代表查询的起始处,4代表返回查询结果的数量。
注:SQL是0开始
相关文章推荐
- 轻松python文本专题-去掉字符串前后空格
- 轻松python文本专题-去掉字符串前后空格
- JavaScript内核笔记01-基础
- mobile 纵向像素布局 全屏幕
- 05 java.lang.String
- AsyncTask 与 Thread+Handler区别
- Windows 7挂载linux的NFS共享文件
- 创建线程方式
- 字符串,基本数据类型对象包装类
- 使用pdb/日志/gdb调试Python http://blog.csdn.net/atfield/article/details/1396735
- POJ-2559-Largest Rectangle in a Histogram-单调栈
- Java两整数相除保留两位小数
- 首先爱自己,然后再爱别人
- Java两整数相除保留两位小数
- Java两整数相除保留两位小数
- HTML5 MUI 手机预览图片,裁剪上传base64,保存数据库
- leetcode 线性表
- 质数筛 nbut1454 Lux
- 避免重复
- 分布式系统的特点以及设计理念