SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with a join query please?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

BluefoxBoy
Starting Member

India
2 Posts

Posted - 09/07/2013 :  03:52:49  Show Profile  Reply with Quote
I have tables named books,supplier, publisher & reason_deleted. The publisher and supplier data are in publisher and supplier tables,books data in books table with publisher and supplier id, and reason_deleted table contains id of books that were deleted. When I write the query

select b.idno,b.title,pub.pub_name,dr.reason,dr.date_deleted,sup.sup_name
from books b inner join reason_deleted dr on dr.book_id=b.idno
inner join publisher pub on b.pub_id=pub.idno inner join supplier sup on b.sup_id=sup.idno

I get results. But among them, some books which are missing supplier/publisher are not shown (means supplier id or publisher id is null in the books table). I need all the books which were deleted whether or not they have supplier or publisher. How can I achieve this?

bitsmed
Constraint Violating Yak Guru

422 Posts

Posted - 09/07/2013 :  04:02:59  Show Profile  Reply with Quote
change the last two "inner join" to "left outer join"
Go to Top of Page

BluefoxBoy
Starting Member

India
2 Posts

Posted - 09/07/2013 :  06:46:05  Show Profile  Reply with Quote
Dank You
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000