我有三个表,例如table1,table2,table3..
我需要一个 mysql 解决方案。
从table1,table2中选择table1.val1,table2.val1并更新返回值,例如..
更新table3设置value=table1.val1,其中value=table2.val1
我的查询不起作用..
update db1.proprietor_profile_tbl as c3 set c3.PPROFILE_profileid=(select c2.COM_id from db2.company_profile_tbl as c1,db1.company_profile_tbl as c2 where c1.COM_name=c2.COM_name and COM_profiletype!=4) where c3.PPROFILE_profileid=c1.COM_id
“where 子句”中存在未知列“c1.COM_id”
最佳答案
UPDATE table3 t3
INNER JOIN table2 t2
ON t3.pcomid = t2.comid
INNER JOIN table1 t1
ON t1.name=t2.name
SET t3.pcomid = t1.comid
关于php - 从两个表中各选择一条记录。通过将另一个值与新表匹配来更新一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21348172/