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? Also pl note that the BOOK_RENTALS is potentially a large table with over 1 million records and BOOK_MASTER is a small table with about 400 records.
Thanks.
Any help is appreciated.
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? Also pl note that the BOOK_RENTALS is potentially a large table with over 1 million records and BOOK_MASTER is a small table with about 400 records.
Thanks.
Any help is appreciated.