I have mysql database with following table...
| id | amount | tax | +----+--------+-----+ | 1 | 500 | | +----+--------+-----+ | 2 | 100 | | +----+--------+-----+
I have to delete amount column but before doing that i want to shift all data of amount row from amount row to tax row. How can it be done using mysql query? Please help.
To copy from one column to another, you can use INSERT INTO SELECT statement.
UPDATE table SET columnB = columnA; This will update every row. This will also work if you want to transfer old value to other column and update the first one: UPDATE table SET columnA = 'new value', columnB = columnA . Like other answer says - don't forget the WHERE clause to update only what's needed.
Move or copy just the contents of a cell Select the row or column that you want to move or copy. In the cell, click where you want to paste the characters, or double-click another cell to move or copy the data. or press Ctrl+V. Press ENTER.
UPDATE mytable SET tax = amount
after you can remove it
ALTER TABLE mytable DROP COLUMN amount;
update TABLE_NAME set tax=amount;
will do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With