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
Release: 2023-08-23 17:25:02
forward
1049 people have browsed it

如果我在一条 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
Copy after login

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
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template