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

MySQLMySQLi Database

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.

raja
Published on 21-Feb-2018 13:21:27
Advertisements