Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2004
    Posts
    113

    Unanswered: Insert into a table........

    Hello,

    I need to insert into a new table. However, I do not want to insert any rows where the email=email and list_acct_no=list_acct_no between 2 other tables.

    This is what I have:

    insert into tjugg_final(list_name, list_acct_no, market_code, email, list_phone_no,
    ad_flag) select distinct O.list_name, O.list_acct_no, L.market_code, L.email, L.list_phone_no, L.ad_flag
    from unsub_final2 o, t_tjuggernaut2 l
    where l.list_acct_no not in o.list_acct_no
    and l.email not in o.email

    Please tell me what is wrong?

  2. #2
    Join Date
    Jan 2004
    Posts
    492
    Well...for one you are missing a join between table o and table l
    Add the join where o.some_id = l.some_id
    Oracle OCPI (Certified Practicing Idiot)

  3. #3
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Is there any relationship between the rows in unsub_final2 and t_tjuggernaut2. The correct query depends on weither you want to exclude a row if email exists ANYWHERE in unsub_final2 or it exists in a subset of the rows. I need additional information.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  4. #4
    Join Date
    Apr 2004
    Posts
    113
    beilstwh,

    Yes the issue is that we one of the developers messed up our master table.
    So now we have created a new table and the rows in unsub_final2 and t_tjuggernaut2 are almost identical but we know at least 41, 000 rows out of the 100,000 are not identical and those are the rows we need inserted into the new table. Also, I do want to exclude a row if email exists ANYWHERE in unsub_final2.

  5. #5
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    are the structures of the three tables the same?

    for example, the following query would insert any record in unsub_final2 that is NOT in t_tjuggernaut2.

    insert into tjugg_final
    select * from unsub_final2
    minus
    select * from t_tjuggernaut2;
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  6. #6
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    enable a PK
    "blast" in all records & ignore errors.
    The PK will prevent duplicates.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  7. #7
    Join Date
    Apr 2004
    Posts
    113
    i would like to thank everyone for all your hellp!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •