lundi 26 janvier 2015

join value in a RETURNING which is not inserted


Im doing an insert from a query which joins two tables, then I want the new ID from the inserted row, and a field from the original row which is not involved in the insert.Is it possible? I get a "column doesn't exist" error.


INSERT INTO new_table (x,y) select A.x,B.y from A join B on A.w = B.z RETURNING id,B.z;


B.z is not being inserted, but is a field which I want to do things afterwards, like the new id.


Thanks.





Aucun commentaire:

Enregistrer un commentaire