Search code examples
mysqlsqlsql-updatemysql-error-1093

MySQL Update statement error


I have two scripts, one for the Insert, and another for Update.

My update button script is using the latest inserted Id, and goes on something like this:

Update tblsurvey
set WouldLikeToBeSeenOnSite = 'sadffas'
and DislikedOnSite = 'asdfsadfsadf'
and OtherNewsWebsitesRead = 'asdfsadfa'
and LikedOnOtherNewsSites = 'asdfsadfas'
and IPAddress = '172.16.0.123'
and DateAnswered = current_date()
where SurveyResponseId in (select max(SurveyResponseId) from tblsurvey);

Apparently, the "where" clause generates an error:

1093 - you cant specify target table 'tblsurvey' for update in FROM clause. 

Is there any other way in which i could use the latest inserted ID of the same table i am updating?

Thanks.


Solution

  • wait a second. why are you using AND to delimit SET claus elements? it must be comma separated.