the way to do this is the classic "unmatched" query, a.k.a. LEFT OUTER JOIN with IS NULL test
strategy: write the left join to look for the matches you ~don't~ want to find
this means all the necessary condition go into the ON clause -- in this case, the date condition
then add a WHERE clause to restrict the results to unmatched rows, i.e. where a NULL is returned in the main join column
Code:
SELECT c.custId
, c.custName
, c.custEmail
FROM tblcustomers AS c
LEFT OUTER
JOIN tblshoporders AS o
ON o.OrderCustId = c.custId
AND o.OrderDate >= CURRENT_DATE - INTERVAL 6 MONTH
WHERE o.OrderCustId IS NULL
Bookmarks