开发者

Mysql Multiplication Operation

How to execute Multiplication Operation in a Mysql Query?

If my query is like th开发者_开发百科is :

"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
    ";

How to execute multiplication operation within this query? say.. multiplication operation btw days_mess and


The multiplication operator is * :

mysql> select 100 * 2;
+---------+
| 100 * 2 |
+---------+
|     200 |
+---------+
1 row in set (0.00 sec)


In your case, if you want to multiply the values of two columns, you can use those columns, with the * operator between them :

select column1 * column2 as result
from your_table
where ...


select (days_mess * anotherFiled) as anyName


Is there something that was too confusing in the docs: MySQL Reference: Arithmetic Functions?

SELECT registration.hosteladmissionno,
    ## ...
    messexp.billmonth,messexp.billyear ,messexp.perdayrate,student_month.days_mess
    ## additionally generated column:
    messexp.perdayrate * student_month.day_mess AS account_payable
    ## ... end additionally generated column

FROM registration, student_month ,messexp,blockexp WHERE student_month.hosteladmissionno = registration.hosteladmissionno


SELECT (student_month.days_mess *  anotehr_field ), 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
    ;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜