I want to insert 2 new columns to an already existing/populated table in my database.
I have 2 columns in an excel file, the columns are called ‘weight’ and ‘color’. The condition is that the values in both these columns are associated with the value in a column called ‘model_number’ (this is unique, the value in this column is not replicated).
The column ‘Model_Number’ is also in the excel file.
My excel file is organised in such a way that it should be easy enough to execute this query.
Excel file sample:
Column Weight_ _ _ _ _ _ _ _ _ Column Color_ _ _ _ _ _ _ _ _ Column Model_Number (this column is already in DB)
3kg_ _ _ _ _ _ _ _ __ _ _ _ _ _ Red _ _ _ _ _ _ _ __ _ _ _ _ 4545
5kg_ _ _ _ _ _ _ _ __ _ _ _ _ _ Green _ _ _ _ _ _ _ __ _ _ _ 8789
2KG_ _ _ _ _ _ _ _ __ _ _ _ _ _ Blue _ _ _ _ _ _ _ __ _ _ _ 7987
3KG _ _ _ _ _ _ _ __ _ _ _ _ _ Blue _ _ _ _ _ _ _ __ _ _ _ _4332
So for example where the value in Column ‘Model_Number’ is 4545 the value 3kg will be added to Column Weight and the value Red will be add to Column Color in the DataBase.
What SQL code do I need to use here?
Do I have to add the 2 new columns first before adding the values?
Also I am concerned that by inserting these 2 new columns and adding values that I will reset the ‘timestamp’ value column in each row which I don’t want to do. Is there a way to keep the original timestamp value?