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.
Related
Im trying to update a longtext type field called 'comment' using a simple sql query in mysql client like this :
Update mytable set comment='Test' where id = 1;
But i'm getting this error
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 'comment='Test' where id = 1' at line 1
Am i missing something ?, thanks in advance.
comment is a reserved word, if you want to have a table/field with that name, you have to quote it (or use the table.fieldname syntax, in case of a field). default in mysql is the backtick for that, so:
update mytable set `comment`='Test' where id = 1;
Found it, it gets solved with this:
update mytable as a set a.comment='Test' where id = 1;
insert into sws(grade) values(100) where student_id='$session_id' & cys='$get_id2'
It shows error as
You have an error in your sql syntax; check manual that corresponds to your MYSQL server version for right syntax to use near 'WHERE student_id='21' & cys='java' at line 1
Use Update Command not Insert
Replace the & with AND (read about MySQL AND syntax).
INSERT syntax cannot have WHERE clause as you used, you might want to use UPDATE.
Basic UPDATE syntax :
UPDATE table_name
SET column1 = value1, column2 = value2...., columnN = valueN
WHERE [condition];
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)
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';
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