Mysql Multiplication Operation

How to perform a multiply operation in a mysql query?

If my request looks like this:

"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 perform the multiplication operation in this query? let's say btw days_mess multiplication operation and

+3
source share
4 answers

Multiplication Operator *:

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 these columns with an operator *between them:

select column1 * column2 as result
from your_table
where ...
+10
source
select (days_mess * anotherFiled) as anyName
+1
source

- : MySQL: ?

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

0
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

All Articles