Questions tagged [mysql-error-1064]

1064 means "syntax error" in MySQL. It shows part of the failing query to help you troubleshoot.

The MySql 1064 error

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 '%s'

indicates a syntax error in a query or in a command submitted to MySQL.

The error message shows a fragment of your query. The fragment starts with the first character of your query that MySQL did not understand. So, it's often helpful to look at the part of your query immediately before the fragment.

Troubleshooting hints

  • Is the first thing in the message a reserved word in MySQL? It can cause an error when you name something with a word like WHERE or ORDER. SELECT WHERE, ORDER FROM TABLE WHERE ORDER=WHERE, for example.
  • Is the character of your query right before the message some kind of punctuation? If so, it might be the wrong punctuation. SELECT a, b, FROM c WHERE a=b has an extra comma after b, so MySQL shows FROM c... as the location of the error.
  • Should some text string be wrapped correctly in quotes earlier in your query? Did you forget to close a quote? SELECT a FROM c WHERE a='title ORDER BY a complains starting at the beginning of the unclosed string title.

Example of interpreting a 1064 message.

For example, take this bit of incorrect DDL:

CREATE TABLE test_table (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    txt VARCHAR(255) NULL DEFAULT NULL COLLATOR 'utf8mb4_general_ci',
    PRIMARY KEY (id) USING BTREE
);

When you try to run it you get this error message.

SQL 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 ''utf8mb4_general_ci', PRIMARY KEY (id) USING BTREE )' at line 3

So, the fragment MySQL couldn't get was this ...

                                                'utf8mb4_general_ci',
    PRIMARY KEY (id) USING BTREE
);

and the stuff immediately before the fragment in the message was this

CREATE TABLE test_table (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    txt VARCHAR(255) NULL DEFAULT NULL COLLATOR 

COLLATOR? No, that's not right. It should be COLLATION. Fix the problem.

See how this goes? Get the statement fragment from the 1064 message, then back up a little bit from where the fragment started. You'll probably find your error.

Other SOers ... don't hesitate to add your hints!

Related tag

1646 questions
274
votes
24 answers

How to grant all privileges to root user in MySQL 8.0

Tried mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; Getting 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…
Praveen
  • 2,740
  • 2
  • 8
  • 8
133
votes
7 answers

How to delete from multiple tables in MySQL?

I am trying to delete from a few tables at once. I've done a bit of research, and came up with this DELETE FROM `pets` p, `pets_activities` pa WHERE p.`order` > :order AND p.`pet_id` = :pet_id AND pa.`id` =…
alex
  • 479,566
  • 201
  • 878
  • 984
130
votes
16 answers

mysql is not recognised as an internal or external command,operable program or batch

I had set the MySQL path, but still getting the same error. Please let me know whether I followed the correct one or not. MySQL location is: C:\Program Files\MySQL\MySQL Server 5.0\bin In Windows, system variables I had set the path as: variable…
hari
  • 1,341
  • 2
  • 14
  • 16
95
votes
4 answers

How to deal with an apostrophe while writing into a MySQL database

I am getting this error: 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 's','portal','','offering','MSNBC','News','','sports','','MSN','Money','','games'' at…
user244333
87
votes
3 answers

How can I fix MySQL error #1064?

When issuing a command to MySQL, I'm getting error #1064 "syntax error". What does it mean? How can I fix it?
eggyal
  • 122,705
  • 18
  • 212
  • 237
87
votes
10 answers

MySQL Error #1133 - Can't find any matching row in the user table

Unable to set password for a user using 3.5.2.2 - phpMyAdmin for 5.5.27 - MySQL. When trying to set the password while logged onto phpMyAdmin as the user, it pops up the following error: #1133 - Can't find any matching row in the user table When…
Tumharyyaaden
  • 2,733
  • 3
  • 19
  • 20
86
votes
4 answers

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax — PHP — PDO

I've looked through all the other StackOverflow (and google) posts with the same problem, but none seemed to address my problem. I am using PDO and PHP. My code: $vals = array( ':from' => $email, ':to' => $recipient, ':name' =>…
willium
  • 2,048
  • 5
  • 25
  • 34
80
votes
3 answers

sql error errno: 121

CREATE TABLE `users` ( `UID` INT UNSIGNED NOT NULL AUTO_INCREMENT , `username` VARCHAR(45) NOT NULL , `password` VARCHAR(100) NULL , `name` VARCHAR(100) NULL , `gender` BIT NULL , `email` VARCHAR(255) NULL , `phone` VARCHAR(30) NOT…
user396420
69
votes
1 answer

Alter multiple columns in a single statement

I am using a query to alter the charset of a column ALTER TABLE `media_value_report` CHANGE `index_page_body` `index_page_body` TEXT CHARACTER SET utf8 NULL DEFAULT NULL i want to do this for other columns main_title, landing_page_body…
Sangram Anand
  • 10,526
  • 23
  • 70
  • 103
68
votes
6 answers

Why does MySQL report a syntax error on FULL OUTER JOIN?

SELECT airline, airports.icao_code, continent, country, province, city, website FROM airlines FULL OUTER JOIN airports ON airlines.iaco_code = airports.iaco_code FULL OUTER JOIN cities ON airports.city_id = cities.city_id FULL OUTER JOIN…
Josh K
  • 28,364
  • 20
  • 86
  • 132
58
votes
4 answers

MySql Inner Join with WHERE clause

Here is my code: SELECT table1.f_id FROM table1 WHERE table1.f_com_id = '430' AND table1.f_status = 'Submitted' INNER JOIN table2 ON table2.f_id = table1.f_id where table2.f_type = 'InProcess' I need information from table1 as all the…
Aditya Kumar
  • 793
  • 1
  • 8
  • 14
39
votes
5 answers

SHOW TABLES statement with multiple LIKE values

mysql> SHOW TABLES like 'cms'; +-------------------------+ | Tables_in_tianyan (cms) | +-------------------------+ | cms | +-------------------------+ 1 row in set (0.00 sec) Result mysql> SHOW TABLES like 'cms' or like…
mysql_go
  • 2,269
  • 4
  • 20
  • 20
38
votes
5 answers

Mysql: execute command denied to user ''@'localhost' for routine error

i got some problem during open my old website. My dataTable show: DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error. After that, I tried to debug my script and found error in mysql: Error…
nunu
  • 2,703
  • 9
  • 33
  • 55
36
votes
5 answers

apache mysql - "packets out of order" on 3306

I just did a fresh install of Apache server 2.2. Everything works. When I go to localhost I get: "It Works!" I just installed mySQL5.5 and when I go to localhost:3306 I just get gibberish: J��� …
Adam
  • 731
  • 2
  • 10
  • 16
35
votes
6 answers

MySQL error: 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

I have the Stored procedure like this: CREATE PROCEDURE ProG() BEGIN SELECT * FROM `hs_hr_employee_leave_quota`; END But it gives the error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL…
Gnanendra
  • 509
  • 3
  • 9
  • 12
1
2 3
99 100