四、select语句

1、检索单个列

select prod_name from products;

2、检索多个列

select prod_name, prod_price from products;

3、检索所有列

select * from products;

4、检索不同的行

select distinct vend_id from products;(vend_id只返回不同的值)

5、限制结果

select prod_name from products limit 开始位置,检索行数;

6、使用完全限定的表名

select products.prod_name from products;

select products.prod_name from crashcourse.products;

五、排序检索数据

1、根据prod_name排序

select prod_name from products order by prod_name;

2、按多个列排序

select prod_id, prod_price, prod_name from products order by prod_price, prod_name;

3、指定排序方向

select prod_id, prod_price, prod_name from products order by prod_price desc;(desc降序,asc升序)

select prod_id, prod_price, prod_name from products order by price_price desc, prod_name;

select prod_price from products order by prod_price desc limit 1;

六、过滤数据

1、使用where子句

select prod_name, prod_price from products where prod_price=2.50;

where支持

=,<>,!=,<,<=,>,>=,between

2、检查单个值

select prod_name, prod_price from products where prod_name = 'fuses';

3、范围检查

select prod_name, prod_price from products where prod_price between 5 and 10;

4、空值检查

select  prod_name from products where prod_price is null;

七、数据过滤

1、and操作符

select prod_id, prod_price, prod_name from products where vend_id = 1003 and prod_price <= 10;

2、or操作符

select prod_name, prod_price from product where vend_id = 1002 or vend_id = 1003;

3、计算次序

select prod_name, prod_price from products where vend_id = 1002 or vend_id = 1003 and prod_price >= 10;(先and在or)

select prod_name, prod_price from products where (vend_id = 1002 or vend_id = 1003 )and prod_price >= 10

4、in操作符

select prod_name, prod_price from products where vend_id in (1002, 1003) order by prod_name;

5、not操作符

select prod_name, prod_price from products where vend_id not in (1002, 1003) order by prod_name;

最新文章

  1. Zabbix(二)--第一台主机监控及触发器
  2. TAR命令详解
  3. SVN使用教程总结[转]
  4. OC基础--Hello Shit
  5. iOS5可能会删除本地文件储存 - Caches 也不安全
  6. MSF溢出实战教程
  7. Atmega8型号细分区别
  8. php 实现文件下载,兼容IE、Firefox、Chrome等浏览器
  9. 【USACO 1.4.2】时钟
  10. (原)mkl的cblas_sgemm和cblas_dgemm
  11. 允许Android随着屏幕转动的控制自由转移到任何地方(附demo)
  12. deeplearning.ai 卷积神经网络 Week 4 特殊应用:人脸识别和神经风格转换 听课笔记
  13. LNK2026 模块对于 SAFESEH 映像是不安全的
  14. ●BZOJ 3551 [ONTAK2010]Peaks(在线)
  15. ERROR: Cannot change version of project facet Dynamic Web Module to 3.0?
  16. This application failed to start because it could not find or load the Qt platform plugin异常
  17. SSM商城项目(十一)
  18. [leetcode]200. Number of Islands岛屿个数
  19. c# WPF 设置窗口一直在其中窗口后面/底层窗口
  20. MCU编程_基础

热门文章

  1. java技术选型
  2. JAVA单向链表实现
  3. JAVA基础知识之jdk下载与安装
  4. iOS 9应用开发教程之ios9的视图
  5. iOS 9应用开发教程之定制应用程序图标以及真机测试
  6. [ 转载 ] Java开发中的23种设计模式详解(转)
  7. [ 原创 ] Java基础5--abstract class和interface的区别
  8. Java 中的浮点数取精度方法
  9. luoguP4279 [SHOI2008]小约翰的游戏 Anti-SG 博弈论
  10. luoguP4208 [JSOI2008]最小生成树计数 矩阵树定理