Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Jan 2005
    Wichita, Kansas, USA
    Thanked 0 Times in 0 Posts

    query criteria syntax (2007)

    I have a table that lists details for orders. Folks can order diplomas ([ItemID] is 18). Some of those who order a diploma also order hand calligraphy ([ItemID] is 19) on that diploma. I am using a query to generate a list of those who DO order ItemID 18, but do NOT order ItemID 19.
    First, is that better done as an expression in the Field row of the query, or in the criteria row with the Field set to ItemID?
    Secondly, how is that syntax to be done?
    Thanks in advance for any help.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: query criteria syntax (2007)

    The SQL could look like this, with the appropriate names substituted:

    SELECT * FROM tblOrders WHERE OrderID In (SELECT OrderID FROM tblOrderDetails WHERE ItemID=18) AND OrderID Not In (SELECT OrderID FROM tblOrderDetails WHERE ItemID=19)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts