Mysql:使用另一个表的select max更新表
这个问题在这里已经有了答案:
一个稍微简单的update
形式可以做到这一点:
UPDATE DB2.paperworks
SET DB2.paperworks.contact_id = (
select max(DB1.contacts.code)
from DB1.contacts
where DB1.contacts.name = DB2.paperworks.name
group by DB1.contacts.code
);
尝试这个:
UPDATE DB2.paperworks
SET DB2.paperworks.contact_id = (
SELECT MAX(DB1.contacts.code)
FROM DB1.contacts
WHERE DB2.paperworks.name = DB1.contacts.name
)
链接地址: http://www.djcxy.com/p/16865.html
上一篇: Mysql: Update table with select max of another table
下一篇: SQL Server 2005 freezes (because of application), need logging