ABu
ABu

Reputation: 12299

MySQL multitable update with repeated rows

Let's suppose the following "template" query:

update ticket inner join event on ticket.event = event.id
   seat.any_field = <expr1>,
   event.any_field = event.any_field + <expr2>
where event.id = <eid> and seat.another_field = <expr3>

Suppose that query affects n seats (the <expr3> expression selects n seats), and <eid> is of course any event identifier. So, all the selected tickets come from the same event.

Of course, if n is for example, 7, that query will have 7 rows, and each row refering to the same event.

In that situation, will the set event.any_field = event.any_field + <expr2> clause be executed n times (once for each row), or just one (because only one event is selected after all)?

In the former case (it is executed n times), it's possible to execute it only once? (appart from doing two different queries, of course).

Upvotes: 0

Views: 24

Answers (0)

Related Questions