![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I combine the built-in-commands (g and G), used for executing a MySQL statement, with each other?
As we know that built-in-commands (\G and \g) send the command to MySQL server for execution and both of them have the different format of the result set. For combining them and getting the result without error, we need to write two queries, one query with \G and other with \g at the end, in a single statement.
Example
mysql> Select * from student\G select * from ratelist\g *************************** 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)
In the example above, MySQL statement first 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 a tabular format.
Advertisements