Mysql之运算的使用


比较运算符

 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

 

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MySQL中,减法运算符用于执行数值的减法操作。当使用减法运算符时,它会将运算符前后的两个数值相减,并返回结果。 例如,使用减法运算符计算100减去50的结果可以写为: SELECT 100 - 50; 在这个例子中,减法运算符将100和50相减,返回结果50。 需要注意的是,在MySQL中,减法运算符只能用于数值相减,不能用于字符串的拼接。如果遇到非数值类型,MySQL会尝试将其转换为数值进行计算,如果转换失败,则将其视为0进行计算。 此外,如果减法运算中的操作数包含NULL值,结果将为NULL。如果减法运算中的操作数为浮点数,结果将为浮点数。 总结起来,在MySQL中,减法运算符用于执行数值的减法操作,返回结果为数值类型。 #### 引用[.reference_title] - *1* [MySQL学习之运算符](https://blog.csdn.net/cyaya6/article/details/126043895)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [MySQL——运算符的使用](https://blog.csdn.net/wpc2018/article/details/122882458)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值