you're using left outer join to locate rows in A for which there is missing a row in B. the more idiomatic SQL for this is:

UPDATE a SET a.y=1 WHERE NOT EXISTS (SELECT * FROM b WHERE a.x = b.x)

works on any DB and performs better too.



On 11/05/2016 09:38 PM, T Johnson wrote:
How do I do an update join using SQLAlchemy core? In MySQL, it'd be something 
like this:

update a left outer join b
on a.x = b.x
set a.y = 1
where b.x is null

In other words, I want to modify a but only for the rows that do not exist in b 
according to my join criterion. The naive attempt that calls update() on the 
join object fails since Join objects don't have an update attribute. As a 
workaround, I'm using text().

A similar question on stackoverflow used an innerjoin and so it could be 
rewritten without needing an explicit join: 
http://stackoverflow.com/q/28274133/1843746


--
SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to