home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / database / 9407 < prev    next >
Encoding:
Text File  |  1993-01-25  |  1.8 KB  |  45 lines

  1. Newsgroups: comp.databases
  2. Path: sparky!uunet!gatech!rpi!uwm.edu!spool.mu.edu!agate!rsoft!mindlink!a269
  3. From: Mischa_Sandberg@mindlink.bc.ca (Mischa Sandberg)
  4. Subject: Re: Help with SQL statement
  5. Organization: MIND LINK! - British Columbia, Canada
  6. Date: Tue, 26 Jan 1993 04:33:30 GMT
  7. Message-ID: <20050@mindlink.bc.ca>
  8. Sender: news@deep.rsoft.bc.ca (Usenet)
  9. Lines: 34
  10.  
  11. > Philip Muench writes:
  12. > In article <1993Jan22.211051.4867@vpnet.chi.il.us> mike@vpnet.chi.il.us
  13. > writes:
  14. > >I have 2 tables lets say I have a Customer table and an order table.
  15. > >I want to query the database for all customers and show their orders
  16. > >for the past month.  I may have more than 1 order for a customer.
  17. > >
  18. > >The problem is that if I don't have an order for a customer, the join will
  19. > >not find a match and that customer will be left out of the report.
  20. > >I still want to show the customer even if no orders are present.
  21. > >Is this possible with SQL ??  was my explanation clear enough ??
  22. >
  23. > Put a false order that you can easily recognize as false in the order
  24. > table for every customer, or at least for every customer that has no
  25. > real order.
  26. > Joins, as you have found, are useless for finding records in one table
  27. > that do not have a corresponding record in the other table.
  28. > -Philip Muench
  29.  
  30. ??? This is a straightforward outer join:
  31. SELECT CUST.CUSTNO, ORDER.TOTAL
  32. FROM CUST, ORDER
  33. WHERE CUST.CUSTNO *= ORDER.CUSTNO
  34.  
  35. ORDER.TOTAL will be <null> where there is no order for that customer.
  36.  
  37.  
  38. --
  39. Mischa Sandberg ... Mischa_Sandberg@mindlink.bc.ca
  40.                  or uunet!van-bc!rsoft!mindlink!Mischa_Sandberg
  41. *-*-*-*-*-*-*-*-*-*-*
  42. Engineers think equations are an approximation of reality.
  43. Physicists think reality is an approximation of the equations.
  44. Mathematicians never make the connection.
  45.