Results 1 to 5 of 5
  1. #1
    Nanuaraq is offline Advanced Beginner
    Windows 7 32bit Access 2013 32bit
    Join Date
    Mar 2017
    Posts
    77

    Wanting to do a query that does not include records from a separate table

    I've a table of companies and I want to query this table for certain characteristics.

    I've also a list of companies that I don't want to appear on the query result. This list is in a separate table.



    How to create a query that gives me results from the table of companies but leaves out those mentioned in the second table?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    make an outer join, in the query , bring in both tables,
    join on Name. Dbl-click the join line.
    set the property to ALL recs in tCompanies, SOME in tExclude.
    bring down CONAME from both tables onto the grid,
    under tExclued.CoName criteria set to IS NULL

    this says, show all companies in tCompanies that are NOT in the tExclude list.

  3. #3
    Nanuaraq is offline Advanced Beginner
    Windows 7 32bit Access 2013 32bit
    Join Date
    Mar 2017
    Posts
    77
    Quote Originally Posted by ranman256 View Post
    make an outer join, in the query , bring in both tables,
    join on Name. Dbl-click the join line.
    set the property to ALL recs in tCompanies, SOME in tExclude.
    bring down CONAME from both tables onto the grid,
    under tExclued.CoName criteria set to IS NULL

    this says, show all companies in tCompanies that are NOT in the tExclude list.

    Oooooh, that is so beautiful. And simple. I like simple.

  4. #4
    Join Date
    Apr 2017
    Posts
    1,679
    Another way (so long you have a single field in both tables to distinguish and identify companies):
    Code:
    SELECT * FROM tblCompanies WHERE CompanyID NOT IN (SELECT CompanyID from ExcludeList)
    or
    Code:
    SELECT * FROM tblCompanies WHERE CompanyNameD NOT IN (SELECT CompanyName from ExcludeList)

  5. #5
    Nanuaraq is offline Advanced Beginner
    Windows 7 32bit Access 2013 32bit
    Join Date
    Mar 2017
    Posts
    77
    Quote Originally Posted by ArviLaanemets View Post
    Another way (so long you have a single field in both tables to distinguish and identify companies):
    Code:
    SELECT * FROM tblCompanies WHERE CompanyID NOT IN (SELECT CompanyID from ExcludeList)
    or
    Code:
    SELECT * FROM tblCompanies WHERE CompanyNameD NOT IN (SELECT CompanyName from ExcludeList)
    Thank you for this addition.

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

Similar Threads

  1. Replies: 3
    Last Post: 02-19-2018, 01:35 PM
  2. Replies: 1
    Last Post: 02-24-2017, 09:31 AM
  3. Replies: 3
    Last Post: 04-29-2015, 04:02 PM
  4. Replies: 4
    Last Post: 03-29-2014, 01:29 AM
  5. Replies: 4
    Last Post: 12-30-2013, 01:49 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