Question

I wrote this simple query statement:

INSERT INTO merchants 
('firstName','lastName') 
VALUES 
('Bob','Smith') 

Sounds very simple but I keep getting this error:

`#1064 - 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 ''firstName','lastName' ) VALUES ('Bob','Smith' )' at line 2

Was it helpful?

Solution

You need to remove the quotes from around firstName and lastName:

INSERT INTO merchants 
(firstName,lastName) 
VALUES 
('Bob','Smith')

Column names are identifiers, and as such are not quoted.

Edit: Column names can be quoted using backticks (`), but this is only necessary if you have column names that contain special characters or column names that match MySQL keywords.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top