Mysql之运算的使用

来源:互联网 发布:ubuntu gnome dock 编辑:程序博客网 时间:2024/06/05 12:01


比较运算符

 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