Results 1 to 10 of 10
  1. #1
    narendrabr is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    21

    Need query to compare first 5 characters of Fname of Tab1 with irst 5 characters Tb2

    Need query to compare first 5 characters of Fname of Tab1 with irst 5 characters Tb2



    Thanks,

  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,521
    Create a query that joins on the two fields. In SQL view, add the Left() function to both sides of the join and see if that works.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    narendrabr is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    21
    Hi,

    I have this query.Could you help me to put Left() function as I am getting syntax error.

    SELECT Table1.[First name], Table1.[Last name], Table1.ZIPCODE, Tabl2.Email
    FROM Table1 LEFT JOIN Tabl2 ON (Table1.ZIPCODE = Tabl2.ZIPCODE) AND (Table1.[Last name] = Tabl2.[Last name]) AND (Table1.[First name] = Tabl2.[First name]);

    I need to return Email ID if the first 5 character ofTabl1 (Fnname) matches with First 5 character of Table2 (Fname) and same condition for other two fields.

    Thanks

  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,521
    This type of thing

    LEFT JOIN Tabl2 ON (Left(Table1.ZIPCODE, 5) =
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    narendrabr is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    21
    Hi ,

    Can you provide complete Query as I am getting syntax error.

    Thanks

  6. #6
    narendrabr is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    21
    Getting syntax error.

    SELECT Table1.[First name], Table1.[Last name], Table1.ZIPCODE, Tabl2.Email
    FROM Table1 LEFT JOIN Tabl2 ON (Left(Table1.ZIPCODE,5) =(Tabl2.ZIPCODE,5) AND (Table1.[Last name] = Tabl2.[Last name]) AND (Table1.[First name] = Tabl2.[First name]);

    Thanks

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You seem to be missing a LEFT at
    =(Tabl2.ZIPCODE,5)
    , but it isn't clear what exactly you want in the result; or what exactly you are comparing zip code, firstname, last name or combinations of these.

    The records that are equal, or the records that are not equal.

    Can you tell us why you chose LEFT JOIN?

  8. #8
    narendrabr is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    21
    Yes I need to Compare all three fields...and I should return Email if all condition met.

    Like Left(Table.fname,5)=Left(Table2.Fname,5)

    I used LEFT Join Because I want all data of Left Table

    Please provide query

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You've already got it:

    Left(Table.fname,5)=Left(Table2.Fname,5)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    The syntax to solve your issue, as Paul said , you've already got it.

    The issue may now be spelling - earlier posts have
    Table1.[First name], Table1.[Last name], Table1.ZIPCODE, Tabl2.Email

    In post #8

    you have ...Left(Table.fname,5)=Left(Table2.Fname,5)

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

Similar Threads

  1. Special characters in Default Value and Query
    By blacksaibot in forum Queries
    Replies: 1
    Last Post: 03-07-2012, 10:36 AM
  2. Replies: 5
    Last Post: 03-10-2011, 02:19 PM
  3. Union query only returning 255 characters
    By jpkeller55 in forum Queries
    Replies: 25
    Last Post: 10-05-2010, 05:51 AM
  4. Replies: 5
    Last Post: 01-28-2010, 09:10 AM
  5. Replies: 2
    Last Post: 08-04-2008, 04:16 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