标签:color man 描述 str tab body 计算 运算 mod
四则运算符号
运算符 | 描述 |
+ | 加法 |
- | 减法 |
* | 乘法 |
/(DIV) | 除法 |
%(MOD) | 求余 |
【1】+加法用法
mysql> SELECT NAME,JOB,SALARY,SALARY+500 MONTHS_AWARD FROM employee_info; #给每位员工每月奖励500元
+-------+----------+--------+-------------+
| NAME | JOB | SALARY | MONTHS_AWARD |
+-------+----------+--------+-------------+
| aly | salesman | 600 | 1100 |
| bob | agent | 1500 | 2000 |
| cindy | salesman | 800 | 1300 |
+-------+----------+--------+-------------+
【2】-减法用法
参照加法
【3】* 乘法用法
mysql> SELECT*FROM employee_info;
+------+-------+------+----------+--------+
| ID | NAME | AGE | JOB | SALARY |
+------+-------+------+----------+--------+
| 1001 | aly | 22 | salesman | 600 |
| 1002 | bob | 23 | agent | 1500 |
| 1003 | cindy | 21 | salesman | 800 |
+------+-------+------+----------+--------+
3 rows in set (0.00 sec)
mysql> SELECT NAME,JOB,SALARY*12 YEARS_SALARY #显示一年的工资
-> FROM employee_info;
+-------+----------+--------------+
| NAME | JOB | YEARS_SALARY |
+-------+----------+--------------+
| aly | salesman | 7200 |
| bob | agent | 18000 |
| cindy | salesman | 9600 |
+-------+----------+--------------+
【4】/ 除法用法
mysql> SELECT NAME,JOB,SALARY,SALARY/30 DAY_SALARY FROM employee_info; #计算每位员工的每天的薪水
+-------+----------+--------+------------+
| NAME | JOB | SALARY | DAY_SALARY |
+-------+----------+--------+------------+
| aly | salesman | 600 | 20.0000 |
| bob | agent | 1500 | 50.0000 |
| cindy | salesman | 800 | 26.6667 |
+-------+----------+--------+------------+
【5】设置显示格式
CONCAT( )命令
mysql> SELECT CONCAT (NAME,‘雇员的年薪为: ‘,SALARY*12) YEARS_SALARY FROM employee_info;
+-------------------------+
| YEARS_SALARY |
+-------------------------+
| aly雇员的年薪为: 7200 |
| bob雇员的年薪为: 18000 |
| cindy雇员的年薪为: 9600 |
+-------------------------+
标签:color man 描述 str tab body 计算 运算 mod
原文地址:https://www.cnblogs.com/python-wen/p/9845971.html