In MySQL, how we can write Multiple-line statement?

MySQLMySQLi Database

We can write multiple-line statements because MySQL determines the end of a statement by looking for the termination semicolon, not by looking for the end of the input line.

Example

mysql> Select *
    -> from
    -> stock_item;
+------------+-------+----------+
| item_name  | Value | Quantity |
+------------+-------+----------+
| Calculator | 15    | 89      |
| Notebooks  | 63    | 40      |
| Pencil     | 15    | 40      |
| Pens       | 65    | 32      |
| Shirts     | 13    | 29      |
| Shoes      | 15    | 29      |
| Trousers   | 15    | 29      |
+------------+-------+----------+
7 rows in set (0.00 sec)

In the example above, we write a single query into multiple lines and MySQL returns the output only after getting the termination semicolon. In this way we can also say that MySQL can recognize liberated-format input, it gathers the input lines but does not accomplish them until it notices the termination semicolon.

raja
Published on 21-Feb-2018 13:26:02
Advertisements