I am not able to find out what is the exact issue. When I remove index param from below mentioned query and try to insert the data it works fine, but trying to add index cause an error. Here is my table schema:
CREATE TABLE IF NOT EXISTS `address_list` (
`email` varchar(100) NOT NULL,
`currency_name` varchar(50) NOT NULL,
`address` varchar(50) NOT NULL,
`label` varchar(100) NOT NULL,
`index` int DEFAULT 0,
`address_type` varchar(50) NOT NULL,
`balance` varchar(500) DEFAULT "0.0",
`timestamp` TIMESTAMP default CURRENT_TIMESTAMP
)
and here is my insert query :
insert into address_list (email,currency_name,address,label,index,address_type) Values ('[email protected]','bitcoin','mgbtUQt7ppCEhxWmvicxrbEDYSom5kNk8X','test address',3,'wallet');
error :
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 'index) Values ('[email protected]','bitcoin','mgbtUQt7ppCEhxWmvicxrbEDYSom5kNk8X'' at line 1
indexis a reserved word, it needs to be quoted. Voting to close this question as a typo.