update amazon-crawler set `flag_images`= '0' where `id`='966'
i get #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 '-crawler set flag_images= '0' where id='966'' at line 1
why syntax error?
amazon-crawler is the table
flag images and id are columns
My guess is that the hyphen in the table name is causing problems, because it is an arithmetic operator. Try also escaping the table name:
UPDATE `amazon-crawler` SET `flag_images`= '0' WHERE `id` = '966';
Note that you should try to avoid using backticks in your query, unless absolutely needed. Using backticks means that any name would potentially work, even one which happens to be a MySQL reserved keyword. Also, I'm guessing that flag_images and id are numeric columns, in which case you should be comparing them against numbers, not strings. So I would write your update as this:
UPDATE `amazon-crawler` SET flag_images= 0 WHERE id = 966;
Here, only the table name has to appear in backticks.
I'm facing a problem with select inside insert statements.
I've take a look at the questions similar to this but still the query is not working.
first, I'm working with MySQL version 5.6.24 with engine InnoDB, and I'm trying to insert this row:
INSERT INTO form (SELECT course_name FROM course WHERE course_id ='1' ), '123456','5','3','6','1','3','6','1','2','5','6','1','4','1','2','3','good','not bad','bad')
I want the first column to be retrieved (which is only one value), but not the other.
I've tried many syntax formats, with VALUES, with semicolon, with more parentheses, etc... but non work. Here is the 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 ' '123456','5','3','6','1','3','6','1','2','5','6','1','4','1','2','3','good','no' at line 1
Thanks.
Use an INSERT-SELECT:
INSERT INTO form
SELECT course_name, '123456','5','3','6','1','3','6','1','2','5','6','1','4','1','2','3','good','not bad','bad'
FROM course
WHERE course_id = '1'
I've the following structure in MySQL 5.6.19.
CREATE TABLE `metadata` (
`md5` char(32) NOT NULL,
`match` enum('none','md5','similarity') DEFAULT NULL
)
And I got an error doing a query like this:
select * from metadata where match = 'md5';
The error is:
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 '= 'md5'' at line 1
There're multiple entries in the table and rows that could match the query. But MySQL refuse to do it. Any idea about the reason?
Thanks!
MATCH is reserved keyword in MySQL: http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords-5-5.html. You should enclose your field name in backticks to make it work:
select * from metadata where `match` = 'md5';
phpmyadmin query not work for single quote / apostrophe.
Not Work
ALTER TABLE 'about_team' CHANGE 'position' 'pp' INT( 11 ) NOT NULL
Work:
ALTER TABLE `about_team` CHANGE `position` `pp` INT( 11 ) NOT NULL
Same query but not work, gives 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 ''about_team' CHANGE 'position' 'pp' INT(11) NOT NULL' at line 1
it is because when you using single quote, it just means it is a STRING. Whereas BACTICK (the second query) means escaping a column.
'about_team' is not equal with `about_team`
'about_team' is STRING
`about_team` is a Table Name
Actually backticks enclosing the names are optional since the names used where not on MySQL Reserved Keyword List.
MySQL Reserved Keywords
Usually, single quotes are used around values while backticks are for table names and column names.
What is the problem with this query?
INSERT INTO acfrac (username,id,count,time) VALUES ("John Smith", 10, 0,2006-06-07 09:44:33.0)
It gives me the following 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 '09:44:33.0)' at line 1
You need to quote your time stamp. In mysql, if the field you're entering is not an integer, it must be quoted.
Try this:
INSERT INTO acfrac (username,id,count,time) VALUES ("John Smith", 10, 0,'2006-06-07 09:44:33.0')
The date and datetime values need to be enclosed in single quotes.