Home >Database >Mysql Tutorial >What happens if I use both the G and the semicolon (;) terminating symbols in a MySQL statement?

What happens if I use both the G and the semicolon (;) terminating symbols in a MySQL statement?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBforward
2023-08-23 17:25:021047browse

如果我在一条 MySQL 语句中同时使用 G 和分号 (;) 终止符号,会发生什么情况?

We know that the \G option sends the command to the MySQL server for execution, and uses the semicolon (;) MySQL to determine the end of the statement. As we all know, their result set formats are different.

Now, if we use these two formats in a MySQL statement, the output will be generated based on: which one of them is encountered by MySQL first. For other cases, MySQL generates an error. It can be understood with the help of the following example -

mysql> Select CURDATE();\G
+------------+
| CURDATE()  |
+------------+
| 2017-11-06 |
+------------+
1 row in set (0.00 sec)
ERROR:
No query specified

In the above MySQL statement, we first used semicolon (;) and then used \G option, so we received the output in tabular format. Afterwards, MySQL will throw an error because we did not specify any query for the \G option.

mysql> Select CURDATE()\G;
*************************** 1. row ***************************
CURDATE(): 2017-11-06
1 row in set (0.00 sec)
    ERROR:
No query specified

In the above MySQL statement, we first used the \G option and then used the semicolon (;), so we received the vertically formatted output. After that, MySQL will throw an error because we did not specify any query for the semicolon (;).

The above is the detailed content of What happens if I use both the G and the semicolon (;) terminating symbols in a MySQL statement?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete