I have following two tables.
Table1 (Columns: ID, SessionID, URL) Note: URL Column currently is empty. Table1 has one record per SessionID.
Table2 (Columns: ID, SessionID, fromURL) Note: Table 2 has multiple records per Session ID.
So in essence, for one SessionID in Table1 there are multiple records in Table2.
Also the value in fromURL column in Table2 is unique for a SessionID.
What I want to do:
1). Select Table2.fromURL where Table1.SessionID = Table2.SessionID with DISTINCT Table2.fromURL.(I will get lot of records from the above statement)
2). For each record in step 1,Insert value from Table2.fromURL into Table1.URL where Table2.SessionID = Table1.SessionID
Phew.. difficult to explain.. i am sure.. easy to implement.Any help would be appreciated. Regards.
UPDATE Table1 SET URL = fromURL FROM Table2 WHERE Table2.SessionID = Table1.SessionID
No comments:
Post a Comment