开发者

What is wrong with this update query? I get "no records changed"

开发者 https://www.devze.com 2023-03-16 13:50 出处:网络
UPDATE sb_reviews SET clients_id=(SELECT clients_id FROM sb_users WHERE id=sb_reviews.users_id) sb_reviews is a table with a users_id and and a newly created clients_id. I\'m trying to grab the c
UPDATE sb_reviews 
SET clients_id=(SELECT clients_id 
                FROM sb_users 
                WHERE id=sb_reviews.users_id)

sb_reviews is a table with a users_id and and a newly created clients_id. I'm trying to grab the clients_id from the sb_users table and put it into the sb_reviews table where sb_users.id=sb_reviews.users_id

This query does not work though, I get no re开发者_如何学Gocords changed.


There is nothing wrong with your query.

In mysql, if the update has no effect (ie the value in the column isn't changing), it reports as not an update.

If you have already run this, you'll get "no records changed" message every run thereafter (unless data in the second table changes, of course).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号