I am trying to achieve an SQL Query that updates all the records from day 13 in a table as follows:
UPDATE
some_table
SET
'col3' = 'col2value',
'col2' = 'col1value',
'col1' = 'aNewCustomValue'
WHERE
day = '13';
What is the best way to achieve this?
In short for each record the value from col3 must become the value from col2, col2 must get the value from col1 and col1 will receive a new custom value.
Thank you!
UPDATE
some_table
SET
col3 = col2,
col2 = col1,
col1 = 'aNewCustomValue'
WHERE
day = '13';
or to be safe if cols have "unsafe" names:
UPDATE
`some_table`
SET
`col3` = `col2`,
`col2` = `col1`,
`col1` = 'aNewCustomValue'
WHERE
`day` = '13';