Escaping confusion with Python 3 + MySQL

Νίκος Βέργος me.on.nzt at gmail.com
Sun Mar 26 22:39:54 EDT 2017


Τη Δευτέρα, 27 Μαρτίου 2017 - 2:27:31 π.μ. UTC+3, ο χρήστης INADA Naoki έγραψε:
> > i dont have to update table set column1 = this value, column2=that value and
> > so on
> 
> Why do you think so?  Did you really read the manual?
> 
> mysql> create table test_update (a int primary key, b int, c int);
> Query OK, 0 rows affected (0.02 sec)
> 
> mysql> insert into test_update values (1, 2, 3);
> Query OK, 1 row affected (0.00 sec)
> 
> mysql> update test_update set (b, c) values (4, 5) where a = 1;
> 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 '(b, c) values (4, 5) where a = 1' at line 1
> 
> mysql> update test_update set b=4, c=5 where a = 1;
> Query OK, 1 row affected (0.01 sec)
> Rows matched: 1  Changed: 1  Warnings: 0
> 
> >
> > It's just when the LIKE clause jumps in that is causing all this trouble....
> 
> Your MariaDB said:
> 
> > check the manual that corresponds to your MariaDB server version for the right syntax to use near '(pagesID, host, ...
> 
> MariaDB / MySQL shows part of your SQL from where they failed to parse.
> In your case, your MariaDB can't parse from '('
> LIKE clause is not problem for this issue?

Yes indeed it is.
I was just so sure that UPDATE was working like INSERT and i was persistent that the WHERE LIKE clause was cauing this.

I'am still surprised that:
> mysql> update test_update set (b, c) values (4, 5) where a = 1;

is failign to parse. It just seems so undoubtly straightforward and correct syntactically.



More information about the Python-list mailing list