Jump to content

SQL query; Please help me I have spent 2 days on this with no progress


suprsnipes

Recommended Posts

In basic terms I want to

 

UPDATE table 1 column 2

 

with the data from table 2 column 2

 

WHERE table 1 column 1 = table 2 column 1

 

After spending 2 days on this and after trying all various methods I'm stumped., it just won't work.

 

table 1 = t1

table 2 = t2

 

t1 column 1 = id

t1 column 2 = type

 

t2 column 1 = id

t2 column 2 = type

 

Can anyone help me?

Link to comment
Share on other sites

Thanks for the reply Michdd.

 

Sorry my definitions of the columns on t2 were slightly incorrect could you please update your suggested code for me.

 

table 1 = t1

table 2 = t2

 

t1 column 1 = id

t1 column 2 = type

 

t2 column 1 = id1

t2 column 2 = type1

Link to comment
Share on other sites

I'm getting an notice: Undefined variable:id on line 9 and line 11.

 

9.   $result = mysql_query('Select `type` FROM `t2` WHERE `id`="'. $id . '" LIMIT 1');
10. $row = mysql_fetch_assoc($result);
11. mysql_query('UPDATE `t1` SET type="' . $row['type'] . '" WHERE id="' . $id . '"');

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.