0

I got an existing table with bunch of columns and values:

+ID    fruit column2 column3
|1     Apple   value   value
|2     Banana   value   value
|3     Orange   value   value
|4     Pear   value   value

Now I want to import another column to this table. The document with the new column I want to import already has all the existing IDs the database got. I then want to order them accordingly next to their own ID number.

I do not want to update a column, I want to add a new column and place the new values in a row where the IDs match in the document and in the database.

3     Orange
2     Yellow
1     Red
4     Pear

The new updated table would then look like this:

+ID    color    fruit column2 column3
|1     Red      Apple   value   value
|2     Yellow   Banana   value   value
|3     Orange   Orange   value   value
|4     Green    Pear   value   value

Then my question is as following: How could this be done? Can tools like phpMyAdmin do this for you automatically? What would you suggest to be the easiest way?

I want to add that this is a document and a database with well-over 8000 rows. And possible solutions are much appreciated.

Matias K.
  • 37
  • 10
  • First of all, do you need a new table, or do you just want to add a field into the existing table? – Pierre François Nov 28 '17 at 08:46
  • Second: if you want some help, give us some lines of SQL code you want us to improve. We will not write it from scratch for you. – Pierre François Nov 28 '17 at 08:48
  • @PierreFrançois I want to add a field into the existing table. I only got the import code which is pretty much useless because importing is not my issue. I did not ask for a code. But some guidance and a push in the right direction is more than enough. – Matias K. Nov 28 '17 at 08:51

0 Answers0