Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Join two tables (on matching column id's)

947891Jul 6 2012 — edited Jul 9 2012
Hello, I am new to the forums, and I did try to read through what I could to make sure I was posting correctly but if I made a mistake please let me know so I can correct myself in the future. Anyway I have been having a bit of trouble figuring out how to combine two tables based on matching id's. What I have been trying to do is take the data in the CID, and DID column from Table 2 and insert it into Table1 where ever the TAG_ID's match.

This is not school-work, and I am not asking for homework help. I have tried multiple SQL queries with no luck. I am still learning albeit slow, but I am progressing. This query (below) shows me what I want, but when I try to commit the script in ApEx it says that it has only inserted 1/4 of the rows.. and when I look for the data it is never there. I thought I needed a SELECT INTO statement... but when I try to run a SELECT INTO statement it keeps saying my TAG_ID column is not valid (even though it is).

Any help is appreciated, even if it is just re-directing me to documentation. I have been working on figuring this out now for over 3 days straight with little progress.

Here is the most recent query that I have been working on:
SELECT Table2.CID,Table2.DID,Table2.TAG_ID
FROM Table2
FULL JOIN Table1
ON Table1.TAG_ID=Table2.TAG_ID

NOTE: The tables below are bare minimum examples, there are a lot more columns in the tables than I care to put down (especially since the additional data is irrelevant for my question); however, if I need to include all of the data I can do that.
Table: Table1 
PK: ID

Name                 Null                 Type
--------------------------------------------------------
ID                   Not Null             NUMBER
TAG_ID                                    VARCHAR2(30)
CID                                       NUMBER
DID                                       NUMBER
Table: Table2
PK: CID

Name                  Null                Type
--------------------------------------------------------
CID                  Not Null           NUMBER
TAG_ID                                  VARCHAR2(30)
DID                                     NUMBER
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 6 2012
Added on Jul 6 2012
11 comments
6,824 views