Mysql之运算的使用
2016-04-21 15:31
671 查看
比较运算符
Select shohin_mei,shohin_bunrui from shohin where hanbai_tanka = 500;
--选出列为500的记录
Select shohin_mei,shohin_bunrui from shohin where hanbai_tanka <> 500;
--选出列不是500的记录
可以使用的比较运算符= 、<>、>=、>、<=、<
Select shohin_id,shohin_bunrui from shohin where hanbai_tanka >= 1000;
Ps:注意不能对NULL进行比较运算符。
---选取不为NULL的记录
Select shohin_mei,shiire_tanka from shohin where shiire_tanka is not NULL;
逻辑运算符
NOT:select shohin_mei,shohin_bunrui from Shohin where not banbai_tanka >= 1000;
And(&&) 与OR(||)
Select shohin_mei,shiire_tanka from shohin where shohin_bunrui = ‘厨房用具’ and hanbai_tanka >= 3000;
Select shohin_mei,shiire_tanka from shohin where shohin_bunrui = ‘厨房用具’ or hanbai_tanka >= 3000;
Select shohin_mei,shohin_bunrui,torokubi from shohin
Where shohin_burui = ‘日用品’ and ( torokubi = ‘2009-09-11’ or torokubi = ‘2009-09-20’);
----这里()的优先级是大于and的,而and单独的优先级是大于or的
Select shohin_mei,shohin_bunrui from shohin where hanbai_tanka = 500;
--选出列为500的记录
Select shohin_mei,shohin_bunrui from shohin where hanbai_tanka <> 500;
--选出列不是500的记录
可以使用的比较运算符= 、<>、>=、>、<=、<
Select shohin_id,shohin_bunrui from shohin where hanbai_tanka >= 1000;
Ps:注意不能对NULL进行比较运算符。
---选取不为NULL的记录
Select shohin_mei,shiire_tanka from shohin where shiire_tanka is not NULL;
逻辑运算符
NOT:select shohin_mei,shohin_bunrui from Shohin where not banbai_tanka >= 1000;
And(&&) 与OR(||)
Select shohin_mei,shiire_tanka from shohin where shohin_bunrui = ‘厨房用具’ and hanbai_tanka >= 3000;
Select shohin_mei,shiire_tanka from shohin where shohin_bunrui = ‘厨房用具’ or hanbai_tanka >= 3000;
Select shohin_mei,shohin_bunrui,torokubi from shohin
Where shohin_burui = ‘日用品’ and ( torokubi = ‘2009-09-11’ or torokubi = ‘2009-09-20’);
----这里()的优先级是大于and的,而and单独的优先级是大于or的
相关文章推荐
- MySQL审计之插件
- MySQL 5.6.14 win32 zip版安装
- Mysql之查询基础select
- Mysql之数据库与sql
- mysql 主从复制
- Mysql游标遍历
- MYSQL的慢查询两个方法
- Windows安装MySQL
- Mysql编码出现错乱问题
- mysql优化
- 报错:Could not load JDBC driver class [com.mysql.jdbc.Driver]
- mysql sql语句
- mysql rand函数种子的使用技巧
- MySql的FIND_IN_SET()查询函数的使用
- Mysql 关键字-保留字
- MySQL中information_schema是什么
- 【Mysql sqlyog工具的相关快捷键总结】
- MySQL ・ InnoDB 文件系统之IO系统和内存管理
- MySql_SQLyog+SQL Assistant实现智能提示
- MySQL审计之General log