As we know that built-in-commands (\G and \g) send the command to MySQL server for execution and with the help of Semicolon (;) MySQL determines the end of the statement. For using all three and getting the result without error, we need to write three queries, one query with \G, one with \g and other with a semicolon (;) in the end, in a single statement.
Example
mysql> 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 example above, MySQL statement encounters \G after the first query, and based on it throws the result set in vertical format and then encounters \g after the second query and based on it throws the result set in tabular format. After that MySQL encounters semicolon (;) and based on it throws the result set in tabular form.
In this way, we can use all of them in a single MySQL statement.