Results 1 to 3 of 3
  1. #1
    Join Date
    May 2010
    Posts
    2

    Unanswered: oracle query help

    hello, the problem is a reference to table1 more than one field table2
    table1
    id (pk)
    code
    --------------
    table2
    id (pk)
    a_id_table1 (fk)
    a_b_id_table1
    a_c_id_table1
    a_d_id_table1
    --------------
    select table1.code /*table1.code (a_b_id_table1), id_table1.code (...)*/ from table1, table2
    where table2.id = table1.id

    how to get the code for all the references table2? sorry for my inglish

  2. #2
    Join Date
    Feb 2006
    Posts
    173
    Provided Answers: 1
    --Lists all rows in table1, if id does not exist in table2, table2 column values will be null
    Code:
    select t1.*, t2.*
     from  table1 t1 left outer join table2 t2 on t1.id = t2.id
    --Lists all rows in table2, if id does not exist in table1, table1 column values will be null
    Code:
    select t2.*, t1.*
     from  table2 t2 left outer join table1 t1 on t2.id = t1.id
    --List rows in table1 where id exists in table2
    Code:
    select t1.*, t2.*
     from  table1 t1 join table2 t2 on t1.id = t2.id
    --List rows in table2 where id exists in table1
    Code:
    select t2.*, t1.*
     from  table2 t2 join table1 t1 on t2.id = t1.id
    hth

  3. #3
    Join Date
    May 2010
    Posts
    2
    tnks, is work for me.
    --Lists all rows in table1, if id does not exist in table2, table2 column values will be null
    Code:

    select t1.*, t2.*
    from table1 t1 left outer join table2 t2 on t1.id = t2.id

Posting Permissions

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