How is it possible to enter multiple MySQL statements on a single line?


As we know that a query consists of MySQL statements followed by a semicolon. We can enter multiple MySQL statements, separated by semicolons, on a single line. Consider the following example −

mysql> Select * from Student; Select * from Student ORDER BY Name;
+--------+--------+--------+
| Name   | RollNo | Grade  |
+--------+--------+--------+
| Gaurav | 100    | B.tech |
| Aarav  | 150    | M.SC   |
| Aryan  | 165    | M.tech |
+--------+--------+--------+
3 rows in set (0.00 sec)

+--------+--------+--------+
| Name   | RollNo | Grade  |
+--------+--------+--------+
| Aarav  | 150    | M.SC   |
| Aryan  | 165    | M.tech |
| Gaurav | 100    | B.tech |
+--------+--------+--------+
3 rows in set (0.07 sec)

In the example above, two statements have been entered on a single line separated by a semicolon and we got the output in sequence.

Updated on: 22-Jun-2020

971 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements