Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> MySQL

วิธีรันคำสั่ง MySQL โดยไม่ต้องใช้ Semicolon ท้ายคำสั่ง


ใช้ \G หรือ \g ท้ายคำสั่งแทน Semicolon:

ใช้ \G (แสดงผลแนวตั้ง)

mysql> Select * from Stock_item\G
*************************** 1. row ***************************
item_name: Calculator
Value: 15
Quantity: 89
*************************** 2. row ***************************
item_name: Notebooks
Value: 63
Quantity: 40
...
7 rows in set (0.00 sec)

ใช้ \g (แสดงผลแบบตาราง)

mysql> Select * from Stock_item\g
+------------+-------+----------+
| item_name  | Value | Quantity |
+------------+-------+----------+
| Calculator |    15 |       89 |
| Notebooks  |    63 |       40 |
| Pencil     |    15 |       40 |
| Pens       |    65 |       32 |
| Shirts     |    13 |       29 |
| Shoes      |    15 |       29 |
| Trousers   |    15 |       29 |
+------------+-------+----------+
7 rows in set (0.00 sec)

สรุป: \G = Vertical format, \g = Tabular format (เหมือน Semicolon)