Page 263 - PYTHON-12
P. 263

+----------------+

                       | 5 + 10             |
                       +----------------+

                       | 15                    |
                       +----------------+

                       +----------------+-------------+
                       | SIN(PI()/4)  | (4+1)*5    |     mysql> SELECT SIN(PI()/4), (4+1)*5;

                       +----------------+-------------+

                       | 0.707107      |         25       |
                       +----------------+-------------+

                       mysql> SELECT 5 * 4 FROM DUAL;

                       +----------------+
                       | 5 * 4                |

                       +----------------+
                       | 20                    |

                       +----------------+
                       mysql> SELECT 47 % 5 FROM DUAL;

                       +----------------+

                       | 47 % 5           |
                       +----------------+

                       | 2                      |
                       +----------------+

                       The modulus (%) operator returns the remainder as the answer after performing the
                       division operation. Hence, the above statement, 47 % 5 shall return the value 2 as the
                       output.
               POINT TO REMEMBER
               In the above statement, DUAL is the default table in MySQL. It is a one-row, one-column dummy table.


                       Evaluating Scalar expression with SELECT statement

                       MySQL  permits calculations  on the contents of the columns  and  then  displays the
                                                                                                                  Relational Database and SQL
                       calculated result using SELECT statement. We can write scalar expression and constant
                       values for the selected columns. If we are taking NULL value in the expression, it shall
                       result in NULL only. Along with NULL, arithmetic operators can be used while evaluating
                       scalar expressions.
                       For example, mysql> SELECT Rollno, Name, Marks + 10 FROM student;





                                                                                                            12.33
   258   259   260   261   262   263   264   265   266   267   268