0

I have to pass a mysqli update query. Following are the three different tables with the situation. I have a user_table with columns

user_id
user_email

I have a webpage_table with columns

webpage_id
first_webpage
second_webpage

I have a user_data_table with only columns

user_id
webpage_id as foreign key

Now I have to update the values of webpage_table where the user_email="johndoe@xyz.com"....

What will be my update mysqli_query() for the above situation...I tried but i'm not able to go any further of where condition.... Below is my attempt

UPDATE `webpage_table` SET `first_webpage`='xyz', `second_webpage`='xyz' 
WHERE
Dharman
  • 30,962
  • 25
  • 85
  • 135

1 Answers1

0

You could use an updated based on join
with the related table

UPDATE `webpage_table` 
INNER JOIN user_data_table d on u.user_id = d.user_id 
      and `webpage_table`.webpage_id = d.webpage_id 
INNER JOIN user_table u.user_email="johndoe@xyz.com"
SET `first_webpage`='xyz',
   `second_webpage`='xyz'
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107