Welcome Guest, Not a member yet? Register   Sign In
Using Database Class to perform updates, combining 2 tables

Hello everybody,

I have an sql query like this:

Lets say we have 2 tables: a USER and a USER_PROFILE
We want to update the USER_PROFILE table row: surname,name,city etc via USER id .
Relationship is 1 USER row has 1 PROFILE row, so table USER has a profile_id in it.
a normal query would be:

UPDATE user_profile
set surname=value,name=value,city=value
where user_profile.id IN
(SELECT user.profile_id
FROM user
WHERE user.id = value)

Can we implement this using codeIgniter s database class?
Updating 1 table s values when we have another s table known key and both tables are related.

Theme © iAndrew 2016 - Forum software by © MyBB