If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Printing output even though no results found

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-21-04, 10:04
jazzyb jazzyb is offline
Registered User
 
Join Date: Apr 2004
Posts: 10
Question Printing output even though no results found

Hi, I've written a report to search an Inventory table using a list of Locations.
The report will output a list of locations with Inventory quantities.
But the problem I have is that if one of the Locations doesn't have any Inventory, then this Location isn't printed on the report.
I know that is what's meant to happen since the SELECT function will only display rows where a match is found, but is there anyway I can display the search criteria (i.e. the locations) even if there is no corresponding value in the Inventory table?

Thanks.
Jaz
Reply With Quote
  #2 (permalink)  
Old 05-21-04, 11:03
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
What reporting tool are you using?

-PatP
Reply With Quote
  #3 (permalink)  
Old 05-21-04, 16:43
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
one word: LEFT OUTER JOIN

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 05-21-04, 16:58
jazzyb jazzyb is offline
Registered User
 
Join Date: Apr 2004
Posts: 10
I'm not using a reporting tool, just SQL written report.

r937: what do you mean by left outer join? sorry for my ignorance.
Reply With Quote
  #5 (permalink)  
Old 05-21-04, 17:02
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
consider

Pets
1 dog
2 cat
3 bird
4 ferret

People
35 curly
38 larry
39 moe

PeoplePets
35 2
35 3
39 1


list all people with pets (INNER join) --

curly cat
curly bird
moe dog

list all people, and their pets if any (LEFT OUTER join) --

curly cat
curly bird
larry NULL
moe dog

list all people and a count of their pets (LEFT OUTER join) --

curly 2
larry 0
moe 1
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 05-25-04, 08:02
jazzyb jazzyb is offline
Registered User
 
Join Date: Apr 2004
Posts: 10
Talking Thanks!

Hi r937, thanks for your help. I've managed to get it working now.

Much appreciated !!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On