MySQL 算术运算符

(1)+ :加法运算
(2)- :减法运算
(3)* :乘法运算
(4)/ :除法运算,返回商
(5)% :求余运算,返回余数

mysql> CREATE TABLE tmp14 ( num INT ) ;

mysql> INSERT INTO tmp14 VALUE(64);

mysql> SELECT num, num+10, num-3, num*3, num/3, num%3 FROM tmp14;
+------+--------+-------+-------+---------+-------+
| num | num+10 | num-3 | num*3 | num/3 | num%3 |
+------+--------+-------+-------+---------+-------+
| 64 | 74 | 61 | 192 | 21.3333 | 1 |
+------+--------+-------+-------+---------+-------+

select
banlinum.id,
banlinum.name,
banlinum.type,
banlinum.xiangmu,
banlinum.num,
xmcz.chanzhi_geshu,
(banlinum.num*xmcz.chanzhi_geshu) chanzhi
from xiangmu_chanzhi_biao xmcz,
(select pb.paiban_id id,
bl.shiji_shiyong_xingming name,
bl.yewu_leixing type,
bl.banli_yewu_one xiangmu,
count(bl.banli_yewu_one) num
from paiban_biao pb,banli_mingxi_biao blselect
banlinum.id,
banlinum.name,
banlinum.type,
banlinum.xiangmu,
banlinum.num,
xmcz.chanzhi_geshu,
(banlinum.num*xmcz.chanzhi_geshu) chanzhi
from xiangmu_chanzhi_biao xmcz,
(select pb.paiban_id id,
bl.shiji_shiyong_xingming name,
bl.yewu_leixing type,
bl.banli_yewu_one xiangmu,
count(bl.banli_yewu_one) num
from paiban_biao pb,banli_mingxi_biao bl
where pb.yidong_gonghao=bl.gong_hao
group by bl.banli_yewu_one,bl.shiji_shiyong_xingming
ORDER BY pb.paiban_id) banlinum
where banlinum.xiangmu=xmcz.banli_yewu
where pb.yidong_gonghao=bl.gong_hao
group by bl.banli_yewu_one,bl.shiji_shiyong_xingming
ORDER BY pb.paiban_id) banlinum
where banlinum.xiangmu=xmcz.banli_yewu

相关推荐