
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we run a MySQL statement without termination semicolon?
With the help of \G or \g option just at the end of the MySQL statement, we can run it without the semicolon. Consider the example below −
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)
The above query with \G (omitting semicolon) returns the result set in a 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)
The above query with \g (omitting semicolon) returns the result set in a tabular format.
- Related Articles
- How can I combine built-in-commands (g and G), used for executing a MySQL statement, with termination symbol semicolon (;) to get output without any error?
- What happens if I use both G and semicolon (;) termination symbol with a single MySQL statement?
- Can we use semicolon as a MySQL DEMILITER?
- How can we use both built-in-commands (G & g) and semicolon (;) in a single MySQL statement?
- How can we run MySQL statements in batch mode?
- How to print a semicolon(;) without using semicolon in C/C++?
- How can we use a MySQL subquery with INSERT statement?
- In MySQL, how we can write Multiple-line statement?
- How can we escape special characters in MySQL statement?
- How can we enter BOOLEAN values in MySQL statement?
- How can we use SIGNAL statement with MySQL triggers?
- How can we use MySQL SELECT without FROM clause?
- How can we enter characters as a BINARY number in MySQL statement?
- How can we specify default values in MySQL INSERT statement?
- How can we create MySQL views without any column list?

Advertisements