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:
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:
id name
1 Oriol
2 Ricard
TABLE 2:
id name
1 Uriol
2 Ricard
And once compared the two tables, I want this:
TABLE 1:
id name
1 Uriol
2 Ricard
maybe this code help you
UPDATE table1 t1, table2 t2
SET t1.name=t2.name, t1.surname=t2.surname
WHERE t1.id=t2.id
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.