Target table not Updatable error

时光总嘲笑我的痴心妄想 提交于 2019-12-01 12:28:11

问题


I need to run this query :

UPDATE (
   SELECT r.* 
   FROM booked r 
   INNER JOIN (
      SELECT a.st_code as from_t
           , b.st_code as to_t 
      FROM `stops_at` a 
      CROSS JOIN `stops_at` b 
      WHERE (a.stop_no < b.stop_no) 
        and (a.train_no = b.train_no) 
        and (a.train_no = '11280')
      ) new 
   ON (r.st_from = new.from_t) 
     and (r.st_to = new.to_t)
     and r.date = '2013-04-16'
   ) temp 
SET temp.seat_ac = temp.seat_ac-5

but on execution it gives an error:

#1288-The target table temp of the UPDATE is not updatable.

Any solutions?


回答1:


I think your UPDATE syntax is incorrect. See if this works:

UPDATE booked r
INNER JOIN (
   SELECT a.st_code as from_t
        , b.st_code as to_t 
   FROM `stops_at` a 
   CROSS JOIN `stops_at` b 
   WHERE (a.stop_no < b.stop_no) 
     and (a.train_no = b.train_no) 
     and (a.train_no = '11280')
   ) new 
ON r.st_from = new.from_t 
  and r.st_to = new.to_t
  and r.date = '2013-04-16' 

SET r.seat_ac = r.seat_ac-5


来源:https://stackoverflow.com/questions/16004750/target-table-not-updatable-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!