I've loaded a csv file(which contains columns studentsID and marks) into a table. Now am loading another csv file into same table(with same columns but with the updated marks of same students). Now it should check for the condition if there is increase in students marks for particular student then the new marks should be updated else no change in marks. Can we use update with load query?If possible how can we do that
Asked
Active
Viewed 32 times
1 Answers
0
This is too long for a comment.
I strongly advocate loading text data into staging tables before loading them into their final tables. This makes it easier to debug any problems with the load. In addition, the staging table can have columns that are all strings, with the conversions in the database -- this can greatly help find problems with the representation of data.
In your case, you can load into a staging table and then use insert . . . on duplicate key update
and do exactly what you want.

Gordon Linoff
- 1,242,037
- 58
- 646
- 786
-
Now I have two tables . am trying to insert the whole data of 2nd table(which is updated data) into first table.I used this ---- INSERT INTO table1 select * from table2 ON DUPLICATE KEY UPDATE marks; its not working. can you help me with this? – lucky Jan 05 '16 at 05:06
-
You need to have the right unique constraints set up. – Gordon Linoff Jan 06 '16 at 03:05