samedi 2 avril 2016

Python SQL Lite update using select query

How to update a table column with a value from another table in sql lite on python.

example,

table1

id name value brand
1  n1   v1    -
2  n2   v2    -

table2

id brand
1  b1

i want to update the table1 brand = b1 for id=1

i am trying to do this

UPDATE table1 r join table2 p on r.id= p.id set r.brand=p.brand

but python throws an error on this statement execution

sqlite3.OperationalError: near "r": syntax error

Any solutions please

Aucun commentaire:

Enregistrer un commentaire