home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases
- Path: sparky!uunet!gatech!rpi!uwm.edu!spool.mu.edu!agate!rsoft!mindlink!a269
- From: Mischa_Sandberg@mindlink.bc.ca (Mischa Sandberg)
- Subject: Re: Help with SQL statement
- Organization: MIND LINK! - British Columbia, Canada
- Date: Tue, 26 Jan 1993 04:33:30 GMT
- Message-ID: <20050@mindlink.bc.ca>
- Sender: news@deep.rsoft.bc.ca (Usenet)
- Lines: 34
-
- > Philip Muench writes:
- > In article <1993Jan22.211051.4867@vpnet.chi.il.us> mike@vpnet.chi.il.us
- > writes:
- > >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 ??
- >
- > 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
-
- ??? This is a straightforward outer join:
- SELECT CUST.CUSTNO, ORDER.TOTAL
- FROM CUST, ORDER
- WHERE CUST.CUSTNO *= ORDER.CUSTNO
-
- ORDER.TOTAL will be <null> where there is no order for that customer.
-
-
- --
- Mischa Sandberg ... Mischa_Sandberg@mindlink.bc.ca
- or uunet!van-bc!rsoft!mindlink!Mischa_Sandberg
- *-*-*-*-*-*-*-*-*-*-*
- Engineers think equations are an approximation of reality.
- Physicists think reality is an approximation of the equations.
- Mathematicians never make the connection.
-