-1

I want to run this query that is to update the table row by setting score as 1 ,where the transactionid is maximum

UPDATE transaction_db SET score=1 WHERE transaction_id = ( SELECT MAX(transaction_id) FROM transaction_db );

ERROR:Table 'transaction_db' is specified twice, both as a target for 'UPDATE' and as a separate source for data

Jens
  • 63,364
  • 15
  • 92
  • 104
  • 2
    Possible duplicate of [MySQL Error 1093 - Can't specify target table for update in FROM clause](http://stackoverflow.com/questions/45494/mysql-error-1093-cant-specify-target-table-for-update-in-from-clause) – Jocelyn Jun 20 '16 at 13:51

1 Answers1

0

Here's one way using limit:

update transaction_db 
set score = 1 
order by transaction_id desc
limit 1;
sgeddes
  • 61,426
  • 6
  • 57
  • 79