1

我需要运行这个查询:

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

但在执行时它给出了一个错误:

#1288-UPDATE 的目标表 temp 不可更新

有什么解决办法吗?

4

1 回答 1

2

我认为您的UPDATE语法不正确。看看这是否有效:

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
于 2013-04-14T22:36:56.300 回答