We know that the built-in commands (\G and \g) send the command to the MySQL server for execution, and with the help of the semicolon (;) MySQL determines the end of the statement. In order to use these three queries and get error-free results, we need to write three queries in one statement, one query using \G, one query using \g, and another query using a semicolon (;) at the end.
Examplemysql> Select * from student\G select * from ratelist\g select NOW(); *************************** 1. row *************************** Name: Gaurav RollNo: 100 Grade: B.tech *************************** 2. row *************************** Name: Aarav RollNo: 150 Grade: M.SC *************************** 3. row *************************** Name: Aryan RollNo: 165 Grade: M.tech 3 rows in set (0.00 sec) +----+------+-------+ | Sr | Item | Price | +----+------+-------+ | 1 | A | 502 | | 2 | B | 630 | | 3 | C | 1005 | | 4 | h | 850 | | 5 | T | 250 | +----+------+-------+ 5 rows in set (0.00 sec) +---------------------+ | NOW() | +---------------------+ | 2017-11-06 18:04:12 | +---------------------+ 1 row in set (0.00 sec)
In the above example, the MySQL statement encounters \G after the first query and throws a vertically formatted result set based on it, and then in the second query After \g is encountered, and based on it throws the result set in tabular format. After that, MySQL encounters the semicolon (;) and throws the result set in tabular form based on it.
This way, we can use all result sets in a single MySQL statement.
The above is the detailed content of How to use built-in commands (G & g) and semicolon (;) together in one MySQL statement?. For more information, please follow other related articles on the PHP Chinese website!