if join?
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: if join?

  1. #1
    Join Date
    Feb 2000
    Posts
    24

    if join?

    I'm trying to do a join on two tables A and B.

    A [id, name]
    B [id, ...]

    I want to join b.id = a.id, however, if there is no match, i want to specify a value for B to match on (ie the first record in the table).

    is that possible?

  2. #2
    Join Date
    May 2001
    Posts
    11
    you may to use Exception
    when no_Data_Found then

    Begin
    Select ...
    from B
    where your want ...;
    end;

  3. #3
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    (there must be a better way)
    Code:
    select 
    b.id,  b.rest, 
    decode(a1.id, NULL, a2.name, a1.name)
    from   b, a a1, a a2
    where  b.id = a1.id(+)
    and    a2.id = first_row_a_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
  •  



Click Here to Expand Forum to Full Width