在查询一个表中的open_date字段去更新create_date字段时出错:
update domain_info a
set a.create_date =
(select open_date from domain_info t where t.domain_name = "www.com" order by t.open_date limit 1)
WHERE domain_name = "www.com"
网上查了,发现在mysql是不允许在同一个表中查询其中一列去更新另外的一列属性的,需要借助一个虚拟表,如下写就可以更新成功了。
update domain_info a
set a.create_date =
(SELECT b.open_date FROM
(select open_date from domain_info t where t.domain_name = "www.com" order by t.open_date limit 1) b)
WHERE domain_name = "www.com"