如何在MySQL查询中执行乘法运算?
如果我的查询是这样的:
"SELECT registration.hosteladmissionno,
registration.student_name,
registration.semester,
student_month.hosteladmissionno,
student_month.student_name,
student_month.semester,
messexp.billmonth,messexp.billyear ,messexp.perdayrate,student_month.days_mess
FROM registration,
student_month ,messexp,blockexp
WHERE student_month.hosteladmissionno = registration.hosteladmissionno
";
如何在此查询中执行乘法运算?说..乘法运算btw days_mess和
解决方法:
乘法运算符是*:
MysqL> select 100 * 2;
+---------+
| 100 * 2 |
+---------+
| 200 |
+---------+
1 row in set (0.00 sec)
在您的情况下,如果要将两列的值相乘,则可以使用这些列,并在它们之间使用*运算符:
select column1 * column2 as result
from your_table
where ...