home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / database / 9469 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  2.7 KB

  1. Path: sparky!uunet!ogicse!pnl-oracle!news
  2. From: jordan@warped.pnl.gov (Randy Jordan)
  3. Newsgroups: comp.databases
  4. Subject: Re: Help with SQL statement
  5. Message-ID: <1993Jan27.001658.7801@oracle.pnl.gov>
  6. Date: 27 Jan 93 00:16:58 GMT
  7. Article-I.D.: oracle.1993Jan27.001658.7801
  8. References: <1993Jan22.211051.4867@vpnet.chi.il.us> <1jrpctINNbqk@CANTOR.MATH.YALE.EDU>
  9. Sender: news@oracle.pnl.gov
  10. Reply-To: jordan@warped.pnl.gov (Randy Jordan)
  11. Distribution: na
  12. Organization: Battelle, Pacific Northwest Laboratory
  13. Lines: 60
  14.  
  15.  
  16. In article <1jrpctINNbqk@CANTOR.MATH.YALE.EDU>, muench-philip@math.yale.edu (Philip Muench) writes:
  17. |>Path: pnl-oracle!ogicse!psgrain!charnel!rat!usc!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!not-for-mail
  18. |>From: muench-philip@math.yale.edu (Philip Muench)
  19. |>Newsgroups: comp.databases
  20. |>Subject: Re: Help with SQL statement
  21. |>Message-ID: <1jrpctINNbqk@CANTOR.MATH.YALE.EDU>
  22. |>Date: Fri, 22 Jan 93 21:48:45 PST
  23. |>Article-I.D.: CANTOR.1jrpctINNbqk
  24. |>References: <1993Jan22.211051.4867@vpnet.chi.il.us>
  25. |>Distribution: na
  26. |>Organization: Yale University Mathematics Dept., New Haven, CT 06520-2155
  27. |>Lines: 29
  28. |>NNTP-Posting-Host: cantor.math.yale.edu
  29. |>
  30. |>In article <1993Jan22.211051.4867@vpnet.chi.il.us> mike@vpnet.chi.il.us writes:
  31. |>>I'm having a problem writing an SQL statement for the following situation
  32. |>>(and I'm not sure its really possible)
  33. |>>
  34. |>>I have 2 tables lets say I have a Customer table and an order table.
  35. |>>I want to query the database for all customers and show their orders
  36. |>>for the past month.  I may have more than 1 order for a customer.
  37. |>>
  38. |>>The problem is that if I don't have an order for a customer, the join will
  39. |>>not find a match and that customer will be left out of the report.
  40. |>>
  41. |>>I still want to show the customer even if no orders are present.
  42. |>>
  43. |>>Is this possible with SQL ??  was my explanation clear enough ??
  44. |>>
  45. |>>Thanks 
  46. |>>
  47. |>>   Mike Kamlet
  48. |>>   mike@vpnet.chi.il.us
  49. |>>
  50. |>>
  51. |>
  52. |>Put a false order that you can easily recognize as false in the order
  53. |>table for every customer, or at least for every customer that has no
  54. |>real order.
  55. |>Joins, as you have found, are useless for finding records in one table
  56. |>that do not have a corresponding record in the other table.
  57. |>-Philip Muench
  58. |> muench@cantor.math.yale.edu 128.36.23.26
  59. |>
  60. --
  61.     select cust_ip, order_number = ''
  62.         from customer 
  63.     where cust_id not null
  64.     union
  65.     select cust_id, order_number
  66.     from orders
  67.     where cust_id not null
  68.     order by cust_id
  69.  
  70. RJ
  71. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  72.     To Thyne Own Self be true...
  73.                                  myne opinions are.
  74. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  75.