How MySQL evaluates the statement written on different lines?

MySQLMySQLi Database

Actually, MySQL determines the end of the statement when it got termination semicolon. Suppose if we are writing a single statement in different lines then after writing the first line, MySQL changes promptly from ‘mysql>’ to ‘->’ which indicates that MySQL has not seen a complete statement yet and is waiting for the rest. When it got semicolon then MySQL executes the statement. It can be understood with the help of the following example −

Example

mysql> Select Id, Name
    -> From
    -> Student_info
    -> ;

+------+---------+
| Id   | Name    |
+------+---------+
| 101  | YashPal |
| 105  | Gaurav  |
| 125  | Raman   |
| 130  | Ram     |
| 132  | Shyam   |
| 133  | Mohan   |
| 150  | Saurabh |
+------+---------+
7 rows in set (0.07 sec)
raja
Published on 22-Feb-2018 07:01:02
Advertisements