UPDATE
+-----+------------------+-------------+
| id | datenum | F1_baro_20_ |
+-----+------------------+-------------+
| 1 | 734152.000000000 | 1005.21 |
| 2 | 734152.006944445 | 1005.26 |
+-----+------------------+-------------+
this is my table
And this is my new table
+-----+------------------+-------------+------------+
| id | datenum | F1_baro_20_ |new column |
+-----+------------------+-------------+------------+
| 1 | 734152.000000000 | 1005.21 | |
| 2 | 734152.006944445 | 1005.26 | |
+-----+------------------+-------------+------------+
I want to insert data to the ‘new_colum’ where old_datenum=new_datenum but I don’t wan to modify the existing data!
Try this.
Add a new column with the following SQL query:
Where
<datatype>can be something like int, text, longtext, varchar(50) – depending on what you need.Then update only this column with SQL queries like this:
or if you need to update a specific row (chosen where the column id is 2):
Here’s the simple SQL query to copy the data from datenum to newColumn:
Run that code once (but with your table name and column name of course) and you’ll see that the data is copied.
Or if you want to do it with, for example, PHP:
This will also copy all the data from datenum to newColumn.