| List: | General Discussion | « Previous MessageNext Message » | |
| From: | (Hal | Date: | February 29 2012 10:56pm |
| Subject: | Re: Getting data from 2 tables if records have same date! | ||
| View as plain text | |||
;>>> 2012/02/29 15:29 -0600, Johnny Withers >>>> Sounds like you need to LEFT JOIN: SELECT * FROM CUSTOMERS LEFT JOIN CALLS ON CUSTOMERS.PHONE = CALLS.PHONE AND CALLS.DATE = "02/28/12" WHERE CUSTOMERS.DATE = "02/28/12" But that would only get customers created on 2/28 AND having a call on 2/28 OR not call at all on 2/28. This would give you customers created on 2/28 with no calls AND customers created on 2/28 with a call on 2/28: SELECT * FROM CUSTOMERS LEFT JOIN CALLS ON CUSTOMERS.PHONE = CALLS.PHONE WHERE CUSTOMERS.DATE = "02/28/12" AND (CALLS.PHONE IS NULL OR CALLS.DATE = "02/28/12") <<<<<<<< Exactly; but I believe that this is the right thing: SELECT * FROM CUSTOMERS LEFT JOIN CALLS USING(PHONE) WHERE CUSTOMERS.DATE = "02/28/12" OR CALLS.DATE = "02/28/12" If you have a hit --PHONE found in both tables--, you will get a record if either date matches, and I believe that you wanted that. If it is a miss --there is no CALLS-record for the PHONE-- CALLS.DATE will be NULL and not equal and only CUSTOMERS.DATE will match a date. And if this works, surely it is clear where to put BETWEEN.
| Thread | ||
|---|---|---|
| • Getting data from 2 tables if records have same date! | LUCi5R | 29 Feb |
| • Re: Getting data from 2 tables if records have same date! | Johnny Withers | 29 Feb |
| • RE: Getting data from 2 tables if records have same date! | LUCi5R | 29 Feb |
| • Re: Getting data from 2 tables if records have same date! | Johnny Withers | 29 Feb |
| • RE: Getting data from 2 tables if records have same date! | LUCi5R | 1 Mar |
| • Re: Getting data from 2 tables if records have same date! | AndrĂ©s Tello | 1 Mar |
| • Re: Getting data from 2 tables if records have same date! | Shawn L Green | 1 Mar |
| • Re: Getting data from 2 tables if records have same date! | David Giragosian | 1 Mar |
| • RE: Getting data from 2 tables if records have same date! | LUCi5R | 1 Mar |
| • Re: Getting data from 2 tables if records have same date! | Shawn L Green | 1 Mar |
| • Re: Getting data from 2 tables if records have same date! | hsv | 1 Mar |
| • RE: Getting data from 2 tables if records have same date! | LUCi5R | 1 Mar |
