Let me see what is wrong with this insert statement? Execute this statement insertintochinaipv4 (from, to) values (1.50.0.0, 1.50.0000255); always prompt: ERROR1064 (42000): fatal; checkthemanualthatco to help me see what is wrong with this insert statement?
Execute this statement insert into chinaipv4 (from, to) values ('1. 50.0.0 ', '1. 50.0000255 ');
Always prompt:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
Corresponds to your MySQL server version for the right syntax to use near 'from,
To) values ('1. 50.0.0 ', '1. 50.0000255') 'at line 1
The table structure is as follows:
+ ------- + ------------- + ------ + ----- + --------- + ---------------- +
| Field | Type | Null | Key | Default | Extra |
+ ------- + ------------- + ------ + ----- + --------- + ---------------- +
| Id | int (11) | NO | PRI | NULL | auto_increment |
| From | varchar (16) | YES | NULL |
| To | varchar (16) | YES | NULL |
+ ------- + ------------- + ------ + ----- + --------- + ---------------- +
------ Solution --------------------
For MySQL
Insert into 'chinaipv4 '('from', 'to') values ('1. 50.0.0', '1. 50.255.255 ');
------ Solution --------------------
From is a reserved mysql word, which must be escaped from'
------ Solution --------------------
Discussion
For MySQL
Insert into 'chinaipv4 '('from', 'to') values ('1. 50.0.0', '1. 50.255.255 ');