Update query help

I have 2 tables T1 and T2.

T1(provider_ssn,clinic,date,start_time,end_time,activity)
T2(provider_ssn,clinic,date,start_time,end_time,activity,sponsor_ssn,is_special_time,link)

What is happening now is, when I insert a row in T1, I insert a row in T2 with all the exact parameters
as T1 and the last 3 as sponsor_ssn = 000000000 and is_special_time = 1 and link = 1

Now, I want to add a new column to T1 called "ak" which is varchar(50) and a new column to T2 called
"webid" which is also varchar(50). Basically I want to have some sort of primary key foreign key relationship
from T1 --> T2.

Now, I have already added the "ak" column to T1 with some unique values. I want to add the same values
to
corresponding rows in T2 in column "webid".

What will be the best way to do this? I understand that there will be some sort of update query,but
I can't seem to figure that out.

Thanks for your help.

Comments

  • What you are missing is some other way to pair the records that you want to make the relationship for. You need a test that will return true only when a record from T1 matches a record from T2; then just put this test in the WHERE clause of the update query. It would probably look something like the following:

    UPDATE T1, T2 SET T2.webid = T1.az
    WHERE T1.provider_ssn=T2.provider_ssn;
    thanks,
    Nick

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion