Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2010
    Posts
    2

    Cannot match same data in different tables

    I have a rather peculiar problem. I have country codes and coutry names listed in a table1. And countries listed in another table2. All i need to do is to update corresponding country codes in table2 . I have written the following query.

    Update Table2,Table1 SET Table2.Countrycode = Table1.Code
    WHERE Table2.Country like '%Trim(Table1.Country)%';



    This does not update any records in my Table2. Physically I can see that the country names are spelled out exactly same in both tables . I don't understand what could be the problem. Could it be the encoding (Eg: Unicode, ANSI) etc.

    Let me know Thanks

    Jitendra

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    You're trying to match the literal string '%Trim(Table1.Country)%'. Presuming you don't need the wildcards try:

    WHERE Table2.Country = Trim(Table1.Country)

    if you do, try:

    WHERE Table2.Country like "'*" & Trim(Table1.Country) & "*'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    Nov 2010
    Posts
    2
    Thanks pbaldy. It worked .

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Happy to help, and welcome to the site!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Unstack Data and Match with Unique ID
    By lukejones in forum Queries
    Replies: 7
    Last Post: 02-24-2014, 08:33 AM
  2. Replies: 1
    Last Post: 11-05-2010, 04:51 AM
  3. data type mis match
    By cowboy in forum Programming
    Replies: 3
    Last Post: 03-12-2010, 11:54 AM
  4. Replies: 1
    Last Post: 06-20-2007, 07:26 PM
  5. Finding data that doesn't match
    By dlhayes in forum Queries
    Replies: 1
    Last Post: 11-11-2006, 08:14 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