asp --> odbc --> mysql, multi query problem.
dbCon.execute("update wp_posts set post_abc = '1234' where ID=1602';");: no problem
dbCon.execute("set #aa=1602;update wp_posts set post_abc = '1234' where ID=#aa;");: error
err message:
[MySQL][ODBC 5.2(w) Driver][mysqld-5.1.45p1-log]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 'update wp_posts........
How can I fix this? SOS!!!
Dislikes answers:
dbCon.execute("set #aa=1602;");
dbCon.execute("update wp_posts set post_abc = '1234' where ID=#aa;");
Add MULTI_STATEMENTS=1 in the connection-string, or enable multiple queries in the DSN entry by going to
Details -> Connection -> Allow multiple statements
Related
I want to create temporary copies of tables with parametrized names for my calculations, but somehow I can't create the tables using %s way.
This issue is very confusing. I have tens of select\insert\update queries using same formatting, but it seems to be not working with CREATE TABLE or CREATE TABLE ... LIKE ...
My code:
query_order = "SELECT Order_ID FROM Reels_In_Order WHERE Reel_Manufacturer_ID = %s"
query_create_copy_order_table = 'CREATE TABLE IF NOT EXISTS %s'
con = mdb.connect(user=self.user, password=self.pswd, database=self.db)
cur = con.cursor()
cur.execute(query_order, (GUI_entry_string,))
order_id = cur.fetchall()
copy_table_name = "Copy_Order_"+order_id[0][0]
print(copy_table_name)
query_copy_order_to_enter = (copy_table_name,)
cur.execute(query_create_copy_order_table, query_copy_order_to_enter)
And it throws an error
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''Copy_Order_2'' at line 1
or this, using CREATE LIKE method
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''Copy_Order_2' LIKE Reels_In_Order' at line 1
I'm out of ideas. Tried changing this ugly "Copy_Order_"+order_id[0][0] with plain "Copy_Order_2" and got the same errors. Tuple is being properly created and passed into the query like in my other select\update queries. Also tried closing and opening connection again, but this isnt the case, same errors.
This question is driving me crazy and I hope you can help. I want to use the following sql for a MySQL-database:
INSERT INTO Prenumeranter (Pren_Namn,Pren_Email) values ('Testing','test#test.com');
UPDATE Prenumeranter SET Pren_kod = encrypt(LAST_INSERT_ID()) WHERE Pren_id = LAST_INSERT_ID();
This code works perfect if I run it in PhpMyAdmin but if I run it on my asp classic page it only gives errors for the LAST_INSERT_ID(). I have tried to rewrite it in different ways, but they all work in PhpMyAdmin but not from the asp page. The error message is:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[MySQL][ODBC 5.1 Driver][mysqld-5.5.30-cll-lve]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 'UPDATE Prenumeranter
SET Pren_kod = encrypt(LAST_INSERT_ID()) WHERE Pren_id = LA' at line 1
/sida.asp, line 122
If I replace the LAST_INSERT_ID with an int value ('85' or something) everything works fine from asp page too so it must be a problem with the LAST_INSERT_ID().
I appreciate all help that can get me back on track...
Hi iam trying to change the path in some links in my WordPress database.
In my table wp_commeentmeta, I am using the syntax:
UPDATE table SET meta_value = REPLACE(meta_value, 'http://articles.mydomain.com', 'http://localhost/articles')
BUT I get the following 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 'table SET meta_value = REPLACE(meta_value,
'http://articles.mydomain.com', 'http' at line 1
Any help on this please?
Please note : I am using phpMyAdmin for this.
Change the table to be the name of your table
UPDATE wp_commeentmeta
SET meta_value = REPLACE(
meta_value,
'http://articles.mydomain.com',
'http://localhost/articles'
);
(Just fyi, the linebreaks aren't important, just makes the query more readable)
We recently switched a database from MSSQL to MySQL and the queries that uses parameters does'nt work anymore.
Here's an example of a query in MSSQL:
SELECT * FROM users u WHERE u.ID = :id
Normally, the parameter browser would popup and ask me for a value for :id, but in MySQL I get 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 ':id'
I tried using a # or ? instead of : and it does'nt work.
Thanks in advance for the help.
syntax is not the same
set #id:=123;
SELECT * FROM users u WHERE u.ID = #id;
Docs for User defined variables
I can't see what is wrong with this SQL:
UPDATE Show
SET EnterOnine = replace(EnterOnine, 'http://projects.example.co.uk', 'http://www.example.co.uk')
WHERE EnterOnine LIKE '%http://projects.example.co.uk%'
I am getting this error when I enter this into PHPmyadmin:
#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 'Show SET EnterOnine = replace(EnterOnine, 'http://projects.example.co.uk' at line 1
Show is a reserved word in mysql, escape with back ticks.
UPDATE `Show` SET ...