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?

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

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 . '"');

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.