0
我试图用视图中的值更新表。目前我使用此代码:与更新加入视图的问题
UPDATE member, temp_status_date SET member.status_date = temp_status_date.status_date WHERE member.status_date != temp_status_date.status_date
这phpMyAdmin是给错误“#1054 - 未知列‘temp_status_date.status_date’在‘where子句’” 什么我做错了什么?根据官方的MySQL文档,这不是正确的语法吗?
它仍然返回一个错误。我在ON子句中添加了另一个条件,因为它需要更新正确的成员。 ! 'UPDATE会员注册temp_status_date ON member.status_date = temp_status_date.status_date AND member.member_id = temp_status_date.member_id SET member.status_date = temp_status_date.status_date' 我得到以下错误:“#1054 - 未知列“temp_status_date .status_date'in'子句'“ – linucksrox
我能够确定问题:我创建的视图没有使用列别名,因此名称实际上是'MAX(member_status_history.status_date)'而不是status_date。 之后的更新工作。谢谢! 'UPDATE构件JOIN temp_status_date ON member.status_date = 'MAX(member_status_history.status_date)' AND member.member_id = temp_status_date.member_id SET member.status_date = 'MAX(member_status_history.status_date)';!' – linucksrox