Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

the system throw a error "You can't specify target table 'screening' for update in FROM clause" How do I completed the update like this?

 UPDATE screening
  SET maileddate = date('Y-m-d', strtotime($mailed_date[$screeningId]))
  WHERE user_id IN (SELECT id FROM users
  INNER JOIN screening ON
  (users.id = screening.users_id
  AND screening.id = {$screeningId}))
  AND date BETWEEN 05-15/2011 AND 11-15-2011
  LIMIT 2
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
131 views
Welcome To Ask or Share your Answers For Others

1 Answer

You would have to remove the LIMIT option (similar to a TOP query in other SQL languages). You are basically saying find me the first 2 items and UPDATE. This may produce unexpected results on tables due to sort order.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...