ODBC Error:You have an error in your SQL syntax; - mysql

I try to update a table, with the value of OPC SIMULATIE:Configured Aliases.PLC1.RPM
But then i get this:
Executing ODBC update: update test set where test = OPC SIMULATIE:Configured Aliases.PLC1.RPM
ODBC Error: [[[MySQL][ODBC 3.51 Driver][mysqld-5.6.11]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 `test` = 'OPC SIMULATIE:Configured Aliases.PLC1.RPM'' at line 1 42000 1064]]
on: Could not ExecDirect: update test set where `test` = 'OPC SIMULATIE:Configured Aliases.PLC1.RPM'
ODBC Error: [[[MySQL][ODBC 3.51 Driver][mysqld-5.6.11]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 `test` = 'OPC SIMULATIE:Configured Aliases.PLC1.RPM'' at line 1 42000 1064]]
on: update test set where `test` = 'OPC SIMULATIE:Configured Aliases.PLC1.RPM'
Can someone please help?

You haven't specified what fields to update:
update test set where test = 'OPC SIMULATIE:Configured Aliases.PLC1.RPM'
should have something like:
update test set field='value' where test = 'OPC SIMULATIE:Configured Aliases.PLC1.RPM'

Related

How to update table set column = null where column = '\' without error of MySQL server version for the right syntax to use near ''\'' at line 1

How to update table set column = null where column = \ in mysql?
I always got error of 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 ''\'' at line 1
You should use '\\'
update students set firstname = null where firstname = '\\'

mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax

i am writing code that reads from one deletes a record my a mysql table but everytime i run it comes up with the error:
mysql.connector.errors.ProgrammingError: 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 '%s' at line 1
this is my code:
ID3 = 3
query4 = ("""DELETE FROM users WHERE userID = %s""")
recordTuple4 = (ID3)
cursor.execute(query4,recordTuple4)

Syntax error on update SQL statement

I'm getting a syntax error when I want to use md5 over url column. Not sure what's wrong with it:
update table {$GLOBALS['tables']['tableame']} set urlhash = md5(url)
Error message:
Database error 1064 while doing query 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 'table tablename set urlhash = md5(url)' at line 1
Try passing md5 in single quotes as that is a string
update {$GLOBALS['tables']['tableame']} set urlhash = 'MD5_URL_HERE'
following is the syntax
UPDATE table_name SET column_name = `new_value' [WHERE condition];

MySQL triggers on the same table

I have some tables. If I update st_income column, then I want to update total_income column, and when I do this I want update next column (income_per_person). I tried this:
IF (NEW.st_income <> OLD.st_income) THEN
SET NEW.total_income=OLD.total_income + (NEW.st_income-OLD.st_income);
END IF
IF(NEW.total_income <> OLD.total_income) THEN
SET NEW.income_per_person=NEW.total_income/(family_mem_numbers+1)/12;
END IF
but it doesn't work.
EDIT
This is return message:
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 'IF(NEW.total_income <> OLD.total_income) THEN SET NEW.income_per_person=NEW' at line

Conditional update/insert in MySQL

I found here a topic about an MySQL IF, ELSE query,i adapted it but i can't figure it out what is the problem with it.
Here is the query:
IF (SELECT * FROM `jos_import03_07_2011` WHERE `cod_oem` = 'OP-4CL') IS NULL THEN
INSERT INTO `jos_import03_07_2011` (`tip_imp`, `tip_produs`, `producator`,
`cod_intern`, `desc`, `cod_oem`, `pret`, `valuta`) VALUES ('Imprimanta Laser',
'Piese Schimb', 'BROTHER', 'BR-200503', '', 'OP-4CL', '338.49', 'EUR');
ELSE UPDATE `jos_import03_07_2011` SET `pret` = '338.49' WHERE `cod_oem` = 'OP-4CL';
END IF;
And here is 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 'IF (SELECT * FROM
`jos_import03_07_2011` WHERE `cod_oem` = 'OP-4CL') IS NULL THE' at line 1
This is the original post:
Conditional mySQL statement. If true UPDATE, if false INSERT
Thanks,
Sebastian
UPDATE
Error code for IF EXISTS:
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 'IF EXISTS (SELECT * FROM
`jos_import03_07_2011` WHERE `cod_oem` = 'OP-4CL') THEN' at line 1
Any reason you can't use the INSERT ... ON DUPLICATE KEY syntax?
INSERT INTO `jos_import03_07_2011` (`tip_imp`, `tip_produs`, `producator`,
`cod_intern`, `desc`, `cod_oem`, `pret`, `valuta`)
VALUES ('Imprimanta Laser', Piese Schimb', 'BROTHER', 'BR-200503', '', 'OP-4CL', '338.49', 'EUR')
ON DUPLICATE KEY UPDATE SET pret = VALUES(pret)
would be far more efficient: one less query and far less code to debug.