mysql - Update problem of related data table
天蓬老师
天蓬老师 2017-05-27 17:39:06
0
2
658

UPDATE a,b SET a.v_publishyear = b.v_publishyear WHERE a.v_id = b.v_e

I want to update the data in table a. There should actually be more than 9,000 pieces of data, but in fact only 120 pieces of data can be updated. How is this going.
Update the publishyear field in table b to the corresponding publishyear field in table a.

But when I perform the operation

SELECT * FROM a table, b table where a table.c field = b table.d field
During this query, more than 9,000 pieces of data can be queried. What is going on?
Me What went wrong in the update data code?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
刘奇

UPDATE is not suitable for using WHERE to associate two tables. So try writing it this way:

UPDATE a LEFT JOIN b ON a.v_id = b.v_e SET a.v_publishyear = b.v_publishyear
伊谢尔伦
update tableA a
    set a.v_publishyeaar=(select b.v_publishyear from tableB b where b.v_e=a.v_id)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!