I'm trying to track the page views by inserting only unique values every 24h.But when I run this query I get a syntax error.
insert ignore into profilepageviews values( '77.777.777.777' , CURRENT_TIMESTAMP, '5') where hitdate NOT LIKE '%2012-06-26%'
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 'where hitdate NOT LIKE '%2012-06-26%'' at line 1
You can not use WHERE clause with INSERT, You might want UPDATE
Related
I have a very strange problem with this code:
Update creature_template SET health_min=(health_min * 0.03) where entry in (select entry from creature where rank ='1');
Update creature_template SET health_max=(health_max * 0.03) where entry in (select entry from creature where rank ='1');
Error occured at:2021-01-07 13:27:46
Line no.:1
Error Code: 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 '='1')' at line 1
I use mysql 8.x and I am a beginner. in mysql 5.x this problem does not exist.
Anyone if can help i would be grateful.
rank is a reserved word in MySQL since version 8.0.2. You need to escape it with backticks
... where `rank` = '1' ...
I got MySQL syntax Error 1064 while I am add new column.
ALTER TABLE `customerdetails` ADD `mobile` DOUBLE(12) NOT NULL ;
where customerdetails is the name of the table.
The Error message is " #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 ') NOT NULL' at line 1
Can somebody help me to solve this problem?
When you are defining column type as DOUBLE you have to define how many decimal places it will use
ALTER TABLE customerdetails ADD mobile DOUBLE(12,2) NOT NULL ;
Also first number (Characteristic) needs to be bigger than second number (Mantissa)
what's wrong with this query?
UPDATE `order` SET `total_no_vat` = IF(`total` IS NULL,NULL,(`total`/(1.10)));
I get an error that I cannot interpret:
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 ') )' at line 1
any clue?
You can simply do:
UPDATE `order` SET `total_no_vat` = `total`/(1.10);
If total is NULL then total/(1.10) evaluates to NULL.
Where is the error in this query?
INSERT INTO chat (`id`,`user`,`message`,`date`)
VALUES (null,'user','test',CURRENT_TIMESTAMP);
This is the error message I receive:
"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 ''id','user','message','date') VALUES (null,'user','test',CURRENT_TIMESTAMP)' at line 1"
if the id is autoincrement then use this instead
INSERT INTO `chat` (`user`,`message`,`date`)
VALUES ('user','test',NOW());
Its difference between single quote ' and backtick `
I have this SQL query:
insert into messages
(message, hash, date_add)
values
('message', 'hash', NOW())
ON DUPLICATE KEY IGNORE
hash is unique, what is wrong with query? i got the 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 'IGNORE' at line 1
According to MySQL doc the syntax should be :
INSERT IGNORE INTO messages (message, hash, date_add)
VALUES('message', 'hash', NOW());