Home > Database > Mysql Tutorial > body text

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

王林
Release: 2023-08-31 14:41:06
forward
572 people have browsed it

如何将用于执行 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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!