Welcome Guest, Not a member yet? Register   Sign In
update database table with joins
#1

[eluser]jerry01[/eluser]
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


Code:
function update_status ($username,$id, $status)
{
      $this->db->join('tbl_updated', 'tbl_joined.id = tbl_updated.join_id');
        $this->db->from('tbl_updated', 'tbl_joined');
        $this->db->where('tbl_updated.id', $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
#2

[eluser]BaRzO[/eluser]
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 ...
#3

[eluser]jerry01[/eluser]
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 !
#4

[eluser]BaRzO[/eluser]
Thank for your time Smile




Theme © iAndrew 2016 - Forum software by © MyBB