Home > Database > Mysql Tutorial > body text

How to run a MySQL statement without a terminating semicolon?

王林
Release: 2023-09-10 22:21:02
forward
1050 people have browsed it

如何运行没有终止分号的 MySQL 语句?

With the help of the \G or \g option at the end of the MySQL statement, we can run it without a semicolon. Consider the following example -

mysql> Select * from Stock_item\G
*************************** 1. row ***************************
item_name: Calculator
    Value: 15
 Quantity: 89
*************************** 2. row ***************************
item_name: Notebooks
    Value: 63
 Quantity: 40
*************************** 3. row ***************************
item_name: Pencil
    Value: 15
 Quantity: 40
*************************** 4. row ***************************
item_name: Pens
  Value : 65
Quantity: 32
*************************** 5. row ***************************
item_name: Shirts
    Value: 13
 Quantity: 29
*************************** 6. row ***************************
item_name: Shoes
    Value: 15
 Quantity: 29
*************************** 7. row ***************************
item_name: Trousers
    Value: 15
 Quantity: 29
7 rows in set (0.00 sec)
Copy after login

The above query with \G (omitting the semicolon) returns the result set in vertical format.

mysql> Select * from Stock_item\g
+------------+-------+----------+
| 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)
Copy after login

The query above with \g (omitting the semicolon) returns the result set in tabular format.

The above is the detailed content of How to run a MySQL statement without a terminating semicolon?. 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