Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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?
 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
Aged Yak Warrior

545 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  
 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