mysql中加減乘除與求余與求平均值以及查詢不等于某數(shù)值的案例
發(fā)表時(shí)間:2023-07-20 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]1.mysql加減乘除操作:mysql> select score,score+5,score-5,score*5,score/5 from 4a;+-------+---------+---...
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求不等于某數(shù)值操作:
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中加減乘除與求余和求平均值以及查詢不等于某數(shù)值的實(shí)例的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注php中文網(wǎng)其它相關(guān)文章!
學(xué)習(xí)教程快速掌握從入門到精通的SQL知識(shí)。