I want to move all data from field_id_41 into field_id_380, where weblog_id = 191
Those two fields belong to the same table: exp_weblog_data
I do not want to run anything without asking here, I started to put this together:
UPDATE
exp_weblog_data
SET
field_id_380 = (SELECT field_id_41 FROM exp_weblog_data
WHERE (field_id_41 != '' and weblog_id = 191))
WHERE
weblog_id = 191
Double-click the cell that contains the data that you want to move or copy. You can also edit and select cell data in the formula bar. 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.
Click the tab for the table with the columns you want to copy and select those columns. From the Edit menu, click Copy. Click the tab for the table into which you want to copy the columns. Select the column you want to follow the inserted columns and, from the Edit menu, click Paste.
In such a case, you can use the following UPDATE statement syntax to update column from one table, based on value of another table. UPDATE first_table, second_table SET first_table. column1 = second_table. column2 WHERE first_table.id = second_table.
To copy from one column to another, you can use INSERT INTO SELECT statement.
Really no need for the subquery. You can just take the value for the other column in the same row, and set it in the first column:
UPDATE
exp_weblog_data
SET
field_id_380 =field_id_41
WHERE
weblog_id = 191
AND
field_id_41 != ''
maybe like this:
UPDATE
exp_weblog_data
SET
field_id_380 =field_id_41, field_id_41 = ''
WHERE
weblog_id = 191
AND
field_id_41 != ''
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