![]() |
Update two tables with each others values - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Update two tables with each others values (/showthread.php?tid=59387) |
Update two tables with each others values - El Forum - 09-29-2013 [eluser]Unknown[/eluser] Hi, there. I have a question. I want to run a simple query like this one: update table_1 t1, table_2 t2 set t1.field = t2.field where t1.id_something = t2.id As you can see, I want to update some values at table_1 using table_2's values. I tried at CI something like this: $this->db->set('t1.field = t2.field'); $this->db->where('t1.id_something = t2.id'); $this->db->update('table_1 t1, table_2 t2'); The problem is at the first line, with the set function. It expects a value as a second parameter and I can't run the query. I'm avoiding the trivial solution that would be $this->db->query('update table_t1....') for obvious reasons. Any ideas? Thanks everyone! |