View Single Post

   
  #1 (permalink)  
Old 02-26-2008, 07:53 AM
aravind.kanda@gmail.com
 
Posts: n/a
Default Combine results based on a value

I need to join two tables where when the join condition is true, it
should return YES and returns NO if it doesnt. Let me try to give an
example:

I have BOOK_RENTALS which contains customer names and books:

JOHN SMITH, BOOKA
JOHN SMITH, BOOKB
JOHN SMITH, BOOKC

and I have a Book Master:

BOOKA
BOOKB
BOOKC
BOOKD
BOOKE

I would like to combine the results from these two tables such that I
get results as follows:

JOHN SMITH, BOOKA, YES
JOHN SMITH, BOOKB, YES
JOHN SMITH, BOOKC, YES
JOHN SMITH, BOOKD, NO
JOHN SMITH, BOOKE, NO

Is this possible in a single sql statement?

Any help is appreciated.
Reply With Quote