Results 1 to 5 of 5
  1. #1
    raghavendran is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    3

    Find an Exact Match in a Access Table column


    How to find an exact match in a Access DB table using Sql Query in VB6 ?
    I know that "Like" keyword will give out all those rows which contain the search-for-string.
    But I want exact match. Can anyone help me please ?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,619
    Use = sign.

    SELECT * FROM tablename WHERE ID=1;

    Other operators:

    <

    >

    <=

    =>

    <>

    Is Null

    Not
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    raghavendran is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    3
    My search-for-string is a sub-string in a column.

    Say, my column is like this.

    25, 32
    24, 31, 58
    32, 14
    56, 322

    And say i search for 32.
    The rows to be returned are : only 1 and 3 and not row # 4 (because it just contain the "32" and it is not equal to 32)

  4. #4
    raghavendran is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    3
    This is how it can be done ....

    Code:
    vStr1 = Chr(32) 'Space
    vStr2 = ","
    vSql = "Select * from 1RecMast where IDs like '%" & vStr1 + txtID.Text & "%' or Trim(IDs) like '%" & txtID.Text & "%' or IDs like '%" & txtID.Text + vStr2 & "%'"

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,619
    Multiple values in one field - not a normalized data structure.

    I don't see how that SQL excludes row 4.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 4
    Last Post: 09-04-2013, 06:40 AM
  2. Replies: 16
    Last Post: 03-13-2012, 03:47 PM
  3. Replies: 8
    Last Post: 03-01-2012, 08:37 AM
  4. Exact Match Hyperlink
    By JeffG3209 in forum Access
    Replies: 5
    Last Post: 06-23-2011, 07:46 PM
  5. Adding text to column if match
    By niihla10 in forum Access
    Replies: 0
    Last Post: 08-26-2009, 01:39 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