8

With a relationship with this question How UPDATE and SELECT at the same time and with this code:

UPDATE table SET foo=1 WHERE boo=2

SELECT * from table WHERE foo=1 AND boo=2

How can I UPDATE and SELECT at the same time with MySQL?

It seems the person asking the existing question uses PostgreSQL. How can I do that in MySQL? It seems there is no returning command in MySQL.

wp78de
  • 18,207
  • 7
  • 43
  • 71
Netorica
  • 18,523
  • 17
  • 73
  • 108
  • 4
    Do not think there is anything for MySQL. – JHS May 23 '12 at 06:07
  • I'm just asking if its possible so I would not be creating two queries... for the sake of creating optimal code(or if its really makes the execution more faster..) – Netorica May 23 '12 at 06:18

1 Answers1

2

Unfortunately, RETURNING is not supported by MySQL and therefore you need to write separate statements.

As an alternative, you can rely on a stored procedure.

The question of whether MySQL has a returning clause equivalent, in general, was addressed here: Mysql returning clause equivalent

wp78de
  • 18,207
  • 7
  • 43
  • 71