2016-06-20 7 views
-1

kombinieren Ich möchte diese Abfrage auszuführen, die durch das Setzen Punktzahl als 1 die Tabellenzeile zu aktualisieren ist, wo die TransactionID, wie ich Update und wählen Sie Abfrage

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

+2

Mögliches Duplikat von [MySQL Error 1093 - Zieltabelle für Aktualisierung in FROM-Klausel nicht angeben] (http://stackoverflow.com/questions/45494/mysql-error-1093-cant-specify-target-table-for -update-in-from-Klausel) – Jocelyn

Antwort

0

Hier ist eine Art und Weise limit mit maximal :

update transaction_db 
set score = 1 
order by transaction_id desc 
limit 1; 
+0

Arbeitete buddy.thanks –

Verwandte Themen