Results 1 to 2 of 2
  1. #1
    TheMaj is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Location
    Shanghai, China
    Posts
    1

    Querying results of previous query....completely lost

    I may be complicating this but I'm trying to analyze the successful results of a previous query. It shouldn't be too hard...I thought.

    I'm trying to determine what my guests are drinking with their Salmon.

    I have a query that returns every check number within a given date range that has Salmon on it. This work fine.

    Now I want to query the db again and get ALL the beverages on those checks. Ultimately I want to determine which alcoholic beverages are on those checks.

    My main table has all the fields necessary for this task. Each row represents the ordering of every menu item throughout the day. In it's simplest form it would look like this.

    CheckNumb, ItemNumb, ItemCategory, BusinessDate, StoreNumb

    In essence I want "all the items on all the checks that have 'salmon' (ItemNumb: 50010) on them".

    Whether this is accomplished in 1, 2 or more queries is not important. I obviously want the results but also want to learn the logic and interaction of the query(s)

    I appreciate any help.....thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    So you need all the beverage records associated with meals that had salmon. This means each record must consider data in other records of same table as criteria.

    SELECT * FROM yourtablename WHERE CheckNumb IN (SELECT CheckNumb FROM yourtablename WHERE ItemNumb=50010) AND ItemCategory="Beverage";

    Assumes ItemNumb is a number field.

    There are other methods but that may be the easiest. Can type the sql statement in query builder SQL View then switch to Design view to see what it looks like there.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 6
    Last Post: 05-12-2012, 03:13 AM
  2. Replies: 1
    Last Post: 03-02-2012, 11:09 AM
  3. Completely new to Access
    By khlmbrg in forum Access
    Replies: 2
    Last Post: 09-22-2011, 08:21 AM
  4. Querying from a Query
    By jo15765 in forum Queries
    Replies: 11
    Last Post: 11-21-2010, 08:12 PM
  5. Query Criteria Lost After Table Update
    By matt4003 in forum Queries
    Replies: 10
    Last Post: 12-29-2009, 10:50 PM

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