Results 1 to 3 of 3
  1. #1
    AccessPower's Avatar
    AccessPower is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    165

    Left Join - return first non match

    I'm looking to alter the query below to pull the first non match from table1. I basically need to make sure that there isn't a match in



    Code:
    SELECT TOP 1 table1.Numbers 
    FROM table1 
    LEFT JOIN qryMPCSwitches5 ON table1.Numbers = qryMPCSwitches5.LOC_NUM 
    WHERE Right(Numbers,1)='0';"
    Right now it's finding the first match between the tables that meets the criteria.

    I will also need to do it to this one, but I assume the concept will be the same:

    Code:
    SELECT TOP 3 table1.Numbers FROM table1 LEFT JOIN qryMPCSwitches5 ON table1.Numbers = qryMPCSwitches5.LOC_NUM WHERE (((Left([Numbers],Len([Numbers])-1)) In (SELECT Left([Numbers],Len([Numbers])-1) AS Prefix FROM table1 GROUP BY Left([Numbers],Len([Numbers])-1) HAVING (((Sum(IIf(Right([Numbers],1)=5,1,0)))>0) AND ((Sum(IIf(Right([Numbers],1)=7,1,0)))>0) AND ((Sum(IIf(Right([Numbers],1)=9,1,0)))>0)))) AND ((Right([Numbers],1)) In (5,7,9)));
    Basically the numbers in the table just can't match.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    the non match would be where the non matching field is null

  3. #3
    AccessPower's Avatar
    AccessPower is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    165
    Got ya! I think I've got it now. Thanks

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

Similar Threads

  1. Replies: 12
    Last Post: 09-10-2015, 05:33 PM
  2. Replies: 3
    Last Post: 06-30-2014, 12:53 AM
  3. Replies: 4
    Last Post: 04-10-2014, 06:36 AM
  4. Replies: 8
    Last Post: 11-04-2011, 06:52 AM
  5. Replies: 3
    Last Post: 02-02-2011, 01:00 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