Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2002
    Posts
    227

    Unanswered: insert into...from more tables!!!

    hi,
    I've these tables:
    table UT (with 500 record):
    User varchar2(32) primary key
    description varchar2(100)

    Table PR (with 10 record):
    Name varchar2(32) primary key
    description varchar2(100)

    Table UT_PR (empty):
    User varchar2(32) foreign key on UT
    Name varchar2(32) foreign key on PR

    I'd like to insert (automatically) into table UT_PR all users that are in tab. UT and for each one to associate the Name from tab. PR.
    i.e. every user will has 10 record.

    Is possible this with a single query oracle?

    Thanks
    raf

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: insert into...from more tables!!!

    Originally posted by raf
    hi,
    I've these tables:
    table UT (with 500 record):
    User varchar2(32) primary key
    description varchar2(100)

    Table PR (with 10 record):
    Name varchar2(32) primary key
    description varchar2(100)

    Table UT_PR (empty):
    User varchar2(32) foreign key on UT
    Name varchar2(32) foreign key on PR

    I'd like to insert (automatically) into table UT_PR all users that are in tab. UT and for each one to associate the Name from tab. PR.
    i.e. every user will has 10 record.

    Is possible this with a single query oracle?

    Thanks
    raf
    I think the following should do it for you:

    INSERT INTO UT_PR (USER, NAME)
    SELECT U.USER, P.NAME FROM UT U, PR P;

Posting Permissions

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