คำว่า select เป็น Reserved Word (คำสงวน) ใน MySQL จึงไม่สามารถใช้เป็นชื่อตารางได้โดยตรง แต่สามารถทำได้โดยปิดชื่อตารางด้วย Backtick (`)
ตัวอย่างการสร้างตาราง
mysql> create table `select`
-> (
-> Number int
-> );
Query OK, 0 rows affected (0.79 sec)
แทรกข้อมูล
mysql> insert into `select` values(10); Query OK, 1 row affected (0.16 sec) mysql> insert into `select` values(20); Query OK, 1 row affected (0.11 sec) mysql> insert into `select` values(30); Query OK, 1 row affected (0.12 sec)
ดึงข้อมูล
mysql> select * from `select`;
ผลลัพธ์
+--------+ | Number | +--------+ | 10 | | 20 | | 30 | +--------+
คำแนะนำ
- หลีกเลี่ยงการใช้ Reserved Words เป็นชื่อตาราง/คอลัมน์ หากเป็นไปได้
- ถ้าบังคับต้องใช้ ให้ปิดด้วย backtick (`) ทุกครั้งที่อ้างอิง
- รายการ Reserved Words ดูได้จากเอกสาร MySQL เวอร์ชันที่ใช้