Database & SQL

Moderators: None (Apply to moderate this forum)
Number of threads: 1194
Number of posts: 2247

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Update query help Posted by dbdoshi on 12 Jun 2002 at 9:52 AM
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.
Report
Re: Update query help Posted by nwdurcholz on 17 Jun 2002 at 1:02 PM
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




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.