Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 40 - Modular_V2.0_SQL_Flipbook
P. 40

    4

                                                                                       MORE ON MYSQL

                          Your Aim

                          to learn about:
                                   Aliasing                                   Performing Calculations in Queries
                                     Using Group By                             Using Order By
                                      Function

                  In the previous chapter, you have learnt about different types of queries like insert, update and

                  delete. In this chapter, you will learn about more about them.

                       ALIASING

                  Aliases are used to give a table or column, a temporary name. Aliases are often used to make column
                  names  more readable  and  presentable.  An  alias  only  exists  for the  duration  of  that query.  It’s  not
                  permanent. Its impact remains during query execution. Alias is valid during the scope of the statement.
                  For example, consider the following table named STUDENTS:
                                                                     Name

                                    Stu_id         Stu_name           Age             Class          Marks
                                      101        Rahim                 18              XII             87
                                      102        Raja                  19              XII             66
                                      103        Riya                  18              XII             55

                      SELECT Stu_name as name, Stu_id as id FROM STUDENTS;
                                                            +-------+------+
                                                            | name  |id    |
                                                            +-------+------+
                                                            | Rahim | 1001 |
                                                            +-------+------+
                                                            | Raja  |  102 |
                                                            +-------+------+
                                                            | Riya  |  103 |
                                                            +--------------+
                  This query will help in displaying results more clear and understandable. The Name and Admission
                  number will be visible during Query results.

                      SELECT (Marks *0.20) as "New Marks" FROM STUDENTS WHERE Marks > 60;

                    38
                          Touchpad MODULAR (Ver. 2.0)

| 35 36 37 38 39 40 41 42 43 44 45 |