Results 1 to 4 of 4
  1. #1
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283

    Wildcard Join???

    I have 2 tables. Both Have a 9 digit Territory field.

    Table 1 contains all territory data examples aaaaaa001, aaaaaa002, aaaaaa003
    Table 2 contains only territories covered aaaaaa001

    In reality as long as the first 6 digits match, it would be considered a covered territory. New territories get added to Table 1 all the time but Table 2 is stagnant, so if a new territory is added to table 1 and should be covered it is never picked up by table 2.



    I am wondering if there is a way to search Left([Table2].[Territory] = Left([Table1].[Territory] so that anything aaaaaa gets pulled back from table 1.

    I hope this is making sense.

    My thought is add a 6 digit field to each table - query on those fields joined and return the 9 digit in the result. But I am not sure if there is an easier or more standard way or if doing this will cause my calculations to get messed up by now have a column with duplicate values.

    Any advice would be appreciated

    Thanks

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    You don't need to create new fields
    Create a Cartesian query with both tables but no link between them
    Add the Territory field from both tables
    Now add a Table2 field Left(Territory,6) and in the criteria for that field enter Left(Table1.Territory,6) so it only picks up records where these are identical
    Run the query
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283
    Quote Originally Posted by ridders52 View Post
    You don't need to create new fields
    Create a Cartesian query with both tables but no link between them
    Add the Territory field from both tables
    Now add a Table2 field Left(Territory,6) and in the criteria for that field enter Left(Table1.Territory,6) so it only picks up records where these are identical
    Run the query

    That is cool. Definitely pointing me in the right direction.
    Thank you so much

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,420
    you can also modify the join in sql, but will not then be editable in the query window, but should be faster (subject to indexing) than a Cartesian query

    SELECT *
    FROM Table1 INNER JOIN Table2 ON Left([Table2].[Territory],6) = Left([Table1].[Territory],6)

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

Similar Threads

  1. Macro using wildcard/LIKE
    By ScottySchultz in forum Macros
    Replies: 2
    Last Post: 01-26-2018, 12:54 PM
  2. Replies: 3
    Last Post: 09-20-2017, 09:50 AM
  3. Wildcard seacrh
    By andyt_2005 in forum Forms
    Replies: 4
    Last Post: 08-02-2014, 02:30 PM
  4. Replies: 9
    Last Post: 12-05-2013, 11:48 AM
  5. Replies: 6
    Last Post: 11-19-2013, 01:38 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