How UPDATE and SELECT at the same time

前端 未结 3 934
無奈伤痛
無奈伤痛 2020-12-10 19:07

I need to update some rows of the tables and then display these rows. Is there a way to do this with one single query and avoid this 2 query ? :

UPDATE table         


        
3条回答
  •  囚心锁ツ
    2020-12-10 19:19

    In PostgreSQL v8.2 and newer you can do this using RETURNING:

    UPDATE table
    SET foo=1
    WHERE boo=2
    RETURNING *
    

提交回复
热议问题