[英]Once I compare two tables how can I update the first table?
Once I have the two tables compared and they give me what has changed, I would like the first table to be updated with the new data from the second one. 一旦将两个表进行了比较,它们给了我改变的地方,我希望用第二个表中的新数据更新第一个表。
This is my code where I put in my phpmyadmin database that compares the two tables: 这是我放入比较两个表的phpmyadmin数据库中的代码:
SELECT
codice_Fiscale,nome,cognome,etichetta,sesso,residenza,
cellulare,email,telefono,id_vitaever
FROM (
SELECT codice_Fiscale,nome,cognome,etichetta,sesso,residenza,
cellulare,email,telefono,id_vitaever
FROM operatore
UNION ALL
SELECT codice_Fiscale,nome,cognome,etichetta,sesso,residenza,
cellulare,email,telefono,id_vitaever
FROM operatoreImport
) tbl
GROUP BY codice_Fiscale,nome,cognome,etichetta,sesso,residenza,
cellulare,email,telefono,id_vitaever
HAVING count(*) = 1
ORDER BY codice_Fiscale
I have this tables: 我有这张桌子:
TABLE 1: 表格1:
id name 身份证名
1 Oriol 1 i
2 Ricard 2里卡德
TABLE 2: 表2:
id name 身份证名
1 Uriol 1乌里奥尔
2 Ricard 2里卡德
And once compared the two tables, I want this: 一旦比较了两个表,我想要这个:
TABLE 1: 表格1:
id name 身份证名
1 Uriol 1乌里奥尔
2 Ricard 2里卡德
maybe this code help you 也许这段代码可以帮助您
UPDATE table1 t1, table2 t2
SET t1.name=t2.name, t1.surname=t2.surname
WHERE t1.id=t2.id
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.