Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why can't I use INSERT INTO … to insert value with whitespace into VARCHAR (ERROR 1064 (42000))?

mysql> INSERT INTO Departments VALUES (1, ‘Accounting’),
    ->    (2, ‘Human Resources’),
    ->    (3, ‘Marketing’);
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 'Resources’),
   (3, ‘Marketing’)' at line 2

I have tried using " instead of ‘, checked the table structure to ensure ‘Human Resources" is a VARCHAR(50) value. I’ve searched the internet and the MySQL 8 manual. I’m at a loss or my brain is vapor-locked. Thanks for the help.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Your insert statement is using curly single quotes instead of straight ones. Use this version and it should work:

INSERT INTO Departments
VALUES (1, 'Accounting'),
       (2, 'Human Resources'),
       (3, 'Marketing');

While your question is really just a typo, the corrective action may be worth mentioning as an answer. You should change your text editor to something which just defaults to using plain ASCII, such as Windows Notepad. Most likely, you typed out that insert statement with some rich text editor, which is not giving you the single quotes you need.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading