Results 1 to 10 of 10
  1. #1
    tabbycat1234 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    26

    Query Showing No Activity

    I have a customer table and a purchase table. I have gotten the query set up so that it shows me all the purchases that a customer has made during a certain time frame. I want to run another query that will show me all the customers that have not purchased anything in a time from. How do you program the criteria so that it will return the customers that have not bought anything.

    The SQL statement is

    SELECT tblcustomers.CompanyName, tblpurchasehistory.ItemBought
    From tblcustomers INNER JOIN tblpurchasehistory ON tblcustomers.CustomerID = tblpurchasehistory.CustomerID;



    Thanks

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  3. #3
    tabbycat1234 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    26
    I have the joins correctly but it is returning all the records

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    If everything is correct, then there wouldn't be a problem.

    Please post the sql for your query.

  5. #5
    tabbycat1234 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    26
    SELECT tblpurchasehistory.CustomerID, Qrycustomerfornoactivity.CustomerID, Qrycustomerfornoactivity.CompanyName, tbluitempurchase.Item
    FROM (Qrycustomerfornoactivity INNER JOIN tblpurchasehistory ON Qrycustomerfornoactivity.CustomerID = tblpurchasehistory.CustomerID) INNER JOIN tbluitempurchase ON tblpurchasehistory.ItemBought = tbluitempurchase.Itempurchaseid;

    (This is showing the item that I have in purchased. I need it to show the customer that has not purchased anything)

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    In your first post you had 2 tables. In this last post you have added a query.

    Please show the sql for the first query. If you look at the link I sent you will see it had a left join.

  7. #7
    tabbycat1234 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    26
    SELECT tblpurchasehistory.CustomerID, tbluitempurchase.Item
    FROM tblpurchasehistory INNER JOIN tbluitempurchase ON tblpurchasehistory.ItemBought = tbluitempurchase.Itempurchaseid;

  8. #8
    tabbycat1234 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    26
    These two tables do not show names of the customer that is why I added the query. I need to have the name of the customer in there also

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Based on your first query, your sql will look something like

    Code:
    SELECT tblcustomers.CompanyName
    , tblpurchasehistory.ItemBought
    From tblcustomers LEFT JOIN tblpurchasehistory 
    ON tblcustomers.CustomerID = tblpurchasehistory.CustomerID
    WHERE tblpurchasehistory.CustomerID Is Null;
    There are great examples on various sql queries here
    http://www.w3schools.com/sql/sql_join_left.asp

  10. #10
    tabbycat1234 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    26
    Thank You that did the job. I really do appreciate the help!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Add activity for each customer
    By nostr4d4m in forum Queries
    Replies: 11
    Last Post: 03-25-2011, 09:08 AM
  2. No activity in last 30 days
    By CMLS in forum Queries
    Replies: 4
    Last Post: 03-18-2011, 11:26 AM
  3. Query Showing Non-Assigned
    By Flash76 in forum Queries
    Replies: 13
    Last Post: 02-03-2011, 01:40 PM
  4. Structured Activity
    By Logix in forum Queries
    Replies: 2
    Last Post: 06-10-2010, 06:05 AM
  5. How to Close access form after no activity
    By russ0670 in forum Forms
    Replies: 1
    Last Post: 05-17-2010, 08:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums