您的位置:首页 > 数据库 > MySQL

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的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: