
- 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
What happens if I use both G and semicolon (;) termination symbol with a single MySQL statement?
As we know that \G option sends the command to MySQL server for execution and with the help of Semicolon (;) MySQL determines the end of the statement. It is also known that both of them have a different format of the result set.
Now, if we will use both of those in MySQL statement then the output would be produced on the basis that which of them is encountered first by MySQL. For others, MySQL will produce 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 use a semicolon (;) first and then \G option hence we received the output in tabular format. Afterward, MySQL throws an error as we have not specified any query for \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 use \G option first and then a semicolon (;) hence we received the output in vertical format. Afterward, MySQL throws an error as we have not specified any query for semicolon (;).
- Related Articles
- How can we use both built-in-commands (G & g) and semicolon (;) in a single MySQL statement?
- 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?
- How can we run a MySQL statement without termination semicolon?
- What happens if I will use integer values as arguments of MySQL LOCATE() function?
- What happens with the output of MySQL EXPORT_SET() function if I will skip both 4th and 5th argument i.e. separator and number of bits?
- How can I combine the built-in-commands (g and G), used for executing a MySQL statement, with each other?
- How can I use MySQL IF() function within SELECT statement?
- What happens if I will assign a value to a MySQL user variable using a statement that returns multiple rows?
- Can we use semicolon as a MySQL DEMILITER?
- What happens if I will delete a row from MySQL parent table?
- How can I use a SELECT statement as an argument of MySQL IF() function?
- How to use COUNT() and IF() in a single MySQL query?
- What happens if I will prepare the statement with the same name without de-allocating the earlier one?
- Can I use SUM() with IF() in MySQL?
- Can I use InnoDB and MyISAM tables in a single database in MySQL?
