say I have a table called 'member' another table 'temp_member", they have the same structure.
Each of them have hundreds of thousands records.
1) How can I update 'member' table with the 'temp_member' table value by matching the id,
I used this, but it is too slow for hundreds of thousands records
UPDATE member, temp_member
member.first_name = temp_member.first_name,
member.last_name = temp_member.last_name,
member.middle_name = temp_member.middle_name
WHERE member.id = temp_member.id
Another approach is that
2) How can I find ids in 'member' that has been updated in 'temp_member'? If I can do it in a best performance way, then I can delete the old records in 'member' and select the new data from 'temp_member' and insert it back to 'member'.
here is the left join approach to find different records between two tables. Is there any other better performance approach?
SELECT tb1.id FROM tb1 LEFT JOIN tb2 ON (tb1.id1=tb2.id1 AND tb1.id2=tb2.id2) WHERE tb2.id1 IS NULL
Thanks!