Home >Database >Mysql Tutorial >How can I combine the built-in commands (g and G) for executing MySQL statements with each other?

How can I combine the built-in commands (g and G) for executing MySQL statements with each other?

王林
王林forward
2023-08-31 14:41:06651browse

如何将用于执行 MySQL 语句的内置命令(g 和 G)相互组合?

As we all know, the built-in commands (\G and \g) send commands to the MySQL server for execution, and the result set formats of the two are different. In order to combine them and get error-free results, we need to write two queries in one statement, one ending with \G and the other ending with \g.

Example H2>
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 above example, the MySQL statement first encounters \G after the first query and based on it throws the result set in vertical format and then after the second \g is encountered after the query and the result set format is thrown in tabular form based on it.

The above is the detailed content of How can I combine the built-in commands (g and G) for executing MySQL statements with each other?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete