Update statement with a inner join
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Update statement with a inner join

  1. #1
    Join Date
    Dec 1999
    Posts
    217

    Update statement with a inner join

    Need some SQL help here ....

    I am trying to convert this statement to Oracle, but I am getting an error. The statement is ...

    update carrier b
    set b.company_key = a.company_key,
    b.carrier_name = a.carrier_name,
    b.carrier = a.carrier,
    b.carrier_code = a.carrier_code,
    b.delivery_days = a.delivery_days,
    b.ship_method = a.ship_method
    from preload_carrier a inner join carrier on
    a.carrier_key = carrier.carrier_key;

    The error I am getting is
    SQL> @update_carrier.sql;
    from preload_carrier a inner join carrier on
    *
    ERROR at line 8:
    ORA-00933: SQL command not properly ended

    In Oracle I understand there is no 'INNER JOIN'. Should I do a select statement within the update statement.

    Your input is highly appreciated.

    -Chintzs

  2. #2
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,460

    Lightbulb

    Try this:
    Code:
    update carrier b
    set (company_key
        ,carrier_name
        ,carrier
        ,carrier_code
        ,delivery_days
        ,ship_method ) = 
        (select company_key
              , carrier_name
              , carrier
              , carrier_code
              , delivery_days
              , ship_method
           from preload_carrier a
          where a.carrier_key = b.carrier_key)
    where exists (
        (select 1
           from preload_carrier a
          where a.carrier_key = b.carrier_key)
    ;
    "The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb

  3. #3
    Join Date
    Dec 1999
    Posts
    217
    Thank You.

    -Chintz

Posting Permissions

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



Click Here to Expand Forum to Full Width