Hi folks,
I have a table and I want to run a SQL update statement that will update one column/field from another in the same DB. So, for examples, I was to update tablename.column2 to the value of tablename.column1. What is the best way to do this? It should be noted that there there is no condition required i.e. no WHERE statement needed - all the rows should be affected.
BTW the table is already modeled.
Page 1 of 1
Updating 1 Column In A Table From Another Column In The Same Table? What is the best method?
#2
Posted 14 January 2013 - 03:41 AM
Hi,
you can use query builder to execute a SQL command (called from a controller action).
See
http://www.yiiframew...uilding-queries
you can use query builder to execute a SQL command (called from a controller action).
See
http://www.yiiframew...uilding-queries
#3
Posted 14 January 2013 - 04:14 AM
Hi mate,
Thanks for the help. I managed to work it out myself in the end - I tried a direct SQL query, which didn't seem to be working. It turns out it was the table schema that was causing an issue where it wouldn't update.
Thanks though.
Thanks for the help. I managed to work it out myself in the end - I tried a direct SQL query, which didn't seem to be working. It turns out it was the table schema that was causing an issue where it wouldn't update.
Thanks though.
Share this topic:
Page 1 of 1

Help













