CodeIgniter Forums

Full Version: update database table with joins
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

In case this is useful to someone (because i could not find any example out there)

i need to update a table with a where clause on a joined table

function update_status ($username,$id, $status)
      $this->db->join('tbl_updated', ' = tbl_updated.join_id');
        $this->db->from('tbl_updated', 'tbl_joined');
        $this->db->where('', $id);
        $this->db->having('tbl_joined.username', $username);
    return $this->db->update('tbl_updated', array('status' => $status));

anyway, somehow this works

any comments or question i'll try and help

El Forum

Hi Jerry,
Thnks for your post.
How can I update users.user_name and groups.group_name ?
And can you pls give an example for sub queries with joins ...

El Forum

sorry buddy, i don't have any example for that...

a bit busy at the mo toinvestigate

good luck though

ps: your english seems fine to me !

El Forum

Thank for your time Smile