SQLite Forum

Can I do this as one liner?
Login
I would look into the UPSERT feature. That allows you to write SELECT statements from whatever tables you like, and feed the results into an INSERT where you can specify ON CONFLICT DO UPDATE to modify rows instead.