• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.