mysql中加减乘除与求余和求平均值以及查询不等于某数值的实例

黄舟
发布: 2017-09-09 15:16:56
原创
5022 人浏览过

1.mysql加减乘除操作:

mysql> select score,score+5,score-5,score*5,score/5 from 4a;
+-------+---------+---------+---------+---------+
| score | score+5 | score-5 | score*5 | score/5 |
+-------+---------+---------+---------+---------+
|    93 |      98 |      88 |     465 | 18.6000 |
|    35 |      40 |      30 |     175 |  7.0000 |
|    46 |      51 |      41 |     230 |  9.2000 |
|    56 |      61 |      51 |     280 | 11.2000 |
|    79 |      84 |      74 |     395 | 15.8000 |
|    91 |      96 |      86 |     455 | 18.2000 |
|    53 |      58 |      48 |     265 | 10.6000 |
|    56 |      61 |      51 |     280 | 11.2000 |
|    58 |      63 |      53 |     290 | 11.6000 |
|    68 |      73 |      63 |     340 | 13.6000 |
|    71 |      76 |      66 |     355 | 14.2000 |
|    93 |      98 |      88 |     465 | 18.6000 |
|    67 |      72 |      62 |     335 | 13.4000 |
|    78 |      83 |      73 |     390 | 15.6000 |
|    88 |      93 |      83 |     440 | 17.6000 |
|    90 |      95 |      85 |     450 | 18.0000 |
|    92 |      97 |      87 |     460 | 18.4000 |
|    47 |      52 |      42 |     235 |  9.4000 |
|    68 |      73 |      63 |     340 | 13.6000 |
|    78 |      83 |      73 |     390 | 15.6000 |
|    81 |      86 |      76 |     405 | 16.2000 |
|    88 |      93 |      83 |     440 | 17.6000 |
+-------+---------+---------+---------+---------+
22 rows in set (0.00 sec)
登录后复制

2.mysql求余操作:

mysql> select score,score%5 from 4a;
+-------+---------+
| score | score%5 |
+-------+---------+
|    93 |       3 |
|    35 |       0 |
|    46 |       1 |
|    56 |       1 |
|    79 |       4 |
|    91 |       1 |
|    53 |       3 |
|    56 |       1 |
|    58 |       3 |
|    68 |       3 |
|    71 |       1 |
|    93 |       3 |
|    67 |       2 |
|    78 |       3 |
|    88 |       3 |
|    90 |       0 |
|    92 |       2 |
|    47 |       2 |
|    68 |       3 |
|    78 |       3 |
|    81 |       1 |
|    88 |       3 |
+-------+---------+
22 rows in set (0.00 sec)
登录后复制

3.mysql求平均值操作:

mysql> select score,avg(score) from 4a;
+-------+------------+
| score | avg(score) |
+-------+------------+
|    93 |    71.6364 |
+-------+------------+
1 row in set (0.00 sec)
登录后复制

4.mysql求不等于某数值操作:

mysql> select score,score!=88 from 4a;     
+-------+-----------+
| score | score!=88 |
+-------+-----------+
|    93 |         1 |
|    35 |         1 |
|    46 |         1 |
|    56 |         1 |
|    79 |         1 |
|    91 |         1 |
|    53 |         1 |
|    56 |         1 |
|    58 |         1 |
|    68 |         1 |
|    71 |         1 |
|    93 |         1 |
|    67 |         1 |
|    78 |         1 |
|    88 |         0 |
|    90 |         1 |
|    92 |         1 |
|    47 |         1 |
|    68 |         1 |
|    78 |         1 |
|    81 |         1 |
|    88 |         0 |
+-------+-----------+
22 rows in set (0.00 sec)
登录后复制

以上是mysql中加减乘除与求余和求平均值以及查询不等于某数值的实例的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!