Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2008
    Posts
    464

    Unanswered: joining 2 tables - 10g

    Hi

    I have 2 tables, one of them containing 200 columns and the other containing 30 cols.

    I wanted to write a query that uses about 70 cols from the first table and 10 from the second.

    Something like:

    Code:
    select datetime, col1+col2+........+col80 AA 
    from table a, table b
    where a.primary_key1=b.primary_key1
    and a.primary_key2=b.primary_key2
    Is there any way to do this other than using aliases?

    E.g., I don't want to do: as it's too cumbersome.

    Code:
    select a.col1, a.col2.........a.col70, b.col1, b.col2...........b.col10
    from table1 a, table2 b
    where 
    a.datetime=b.datetime
    a.primary_key1=b.primary_key1
    and a.primary_key2=b.primary_key2
    Last edited by shajju; 10-28-13 at 04:52.

  2. #2
    Join Date
    Dec 2007
    Posts
    253

    Red face

    You have to list the columns that you want.

  3. #3
    Join Date
    Aug 2008
    Posts
    464
    Thanks. The columns are all of 'number' type with the exception of datetime (date) and one py-key col being varchar(2) type.

  4. #4
    Join Date
    Dec 2007
    Posts
    253
    OK, you still have to list the columns that you want to display, and you'll need to qualify them with either the table name or an appropriate alias if there are any column names common across the two tables (and I'd recommend qualifying them even if there isn't)

Posting Permissions

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