hi all...
i want to update one table from another table. Let's say there are table A and table B. the table structure between these two are quite similar. Table A is an old table and table B is a new table. Table A holds old data and some new data while table B holds the latest data. I want to update table A with values in table B and if there are no record match in table A, a new record will inserted in record A.
My question is, how can i do this using MySql command ONLY? Can I do that? I tried using PHP and it'll take hours to finish, since i have thousands of data.
the pseudo is something like this (PHP):
- n = 0
- get all data in table B LIMIT n,500
- loop record
- check table A if record exists
- if records exists, update record
- else add new record
- end while
- redirect to same page and carry ( n + 500 )
pls tell me if u guys need more explanation
btw, i'm using MySql ver 3.23.41
thx in advance..