当前位置: 移动技术网 > IT编程>数据库>MSSQL > SQL必知必会笔记过滤数据

SQL必知必会笔记过滤数据

2019年04月30日  | 移动技术网IT编程  | 我要评论

包青天之打龙袍,专利,恶少 别惹我

sql必知必会笔记过滤数据

 

在同时使用order by 和where 子句时,应该让order by 位于 where 之后,否则将会产生错误

 

where子句操作符

 

 

范围值检查

 

使用between 操作符,示例:

 

select prod_name, prod_price

from products

where prod_price between 5 and 10;

 

2. 高级数据过滤

 

组合where子句

 

and操作符

 

where 子句中的关键字,用来指示检索满足所有给定条件的行:

 

 

from products

where vend_id = 'dll01' and prod_price <= 4;

 

 

 

or操作符

 

where子句中使用的关键字,用来表示检索匹配任一给定条件的行:

 

 

select prod_name, prod_price

from products

where vend_id = 'dll01' or vend_id = ‘brs01’;

 

 

 

in操作符

 

where 子句中用来指定要匹配值的清单的关键字,功能与or 相当:

 

 

select prod_name, prod_price

from products

where vend_id in ( 'dll01', 'brs01' )

order by prod_name;

 

 

 

not操作符

 

where 子句中用来否定其后条件的关键字:

 

 

select prod_name

from products

where not vend_id = 'dll01'

order by prod_name;

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网