home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!pnl-oracle!news
- From: jordan@warped.pnl.gov (Randy Jordan)
- Newsgroups: comp.databases
- Subject: Re: Help with SQL statement
- Message-ID: <1993Jan27.001658.7801@oracle.pnl.gov>
- Date: 27 Jan 93 00:16:58 GMT
- Article-I.D.: oracle.1993Jan27.001658.7801
- References: <1993Jan22.211051.4867@vpnet.chi.il.us> <1jrpctINNbqk@CANTOR.MATH.YALE.EDU>
- Sender: news@oracle.pnl.gov
- Reply-To: jordan@warped.pnl.gov (Randy Jordan)
- Distribution: na
- Organization: Battelle, Pacific Northwest Laboratory
- Lines: 60
-
-
- In article <1jrpctINNbqk@CANTOR.MATH.YALE.EDU>, muench-philip@math.yale.edu (Philip Muench) writes:
- |>Path: pnl-oracle!ogicse!psgrain!charnel!rat!usc!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!not-for-mail
- |>From: muench-philip@math.yale.edu (Philip Muench)
- |>Newsgroups: comp.databases
- |>Subject: Re: Help with SQL statement
- |>Message-ID: <1jrpctINNbqk@CANTOR.MATH.YALE.EDU>
- |>Date: Fri, 22 Jan 93 21:48:45 PST
- |>Article-I.D.: CANTOR.1jrpctINNbqk
- |>References: <1993Jan22.211051.4867@vpnet.chi.il.us>
- |>Distribution: na
- |>Organization: Yale University Mathematics Dept., New Haven, CT 06520-2155
- |>Lines: 29
- |>NNTP-Posting-Host: cantor.math.yale.edu
- |>
- |>In article <1993Jan22.211051.4867@vpnet.chi.il.us> mike@vpnet.chi.il.us writes:
- |>>I'm having a problem writing an SQL statement for the following situation
- |>>(and I'm not sure its really possible)
- |>>
- |>>I have 2 tables lets say I have a Customer table and an order table.
- |>>I want to query the database for all customers and show their orders
- |>>for the past month. I may have more than 1 order for a customer.
- |>>
- |>>The problem is that if I don't have an order for a customer, the join will
- |>>not find a match and that customer will be left out of the report.
- |>>
- |>>I still want to show the customer even if no orders are present.
- |>>
- |>>Is this possible with SQL ?? was my explanation clear enough ??
- |>>
- |>>Thanks
- |>>
- |>> Mike Kamlet
- |>> mike@vpnet.chi.il.us
- |>>
- |>>
- |>
- |>Put a false order that you can easily recognize as false in the order
- |>table for every customer, or at least for every customer that has no
- |>real order.
- |>Joins, as you have found, are useless for finding records in one table
- |>that do not have a corresponding record in the other table.
- |>-Philip Muench
- |> muench@cantor.math.yale.edu 128.36.23.26
- |>
- --
- select cust_ip, order_number = ''
- from customer
- where cust_id not null
- union
- select cust_id, order_number
- from orders
- where cust_id not null
- order by cust_id
-
- RJ
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- To Thyne Own Self be true...
- myne opinions are.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-