Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2003
    Posts
    8

    Red face Unanswered: LIKE '[]' wildcard

    Hey All
    I have encounter a matching problem during using SELECT ... LIKE statement.

    I perform a SELECT statement as shown

    SELECT pPartCode, pAccount FROM tblParts
    WHERE pPartDesc
    LIKE '[CONN-3] connectors only for field termination of 1127 cable'


    The search string
    [CONN-3] connectors only for field termination of 1127 cable
    consist of []

    But when i perform a SELECT statement above and it return nothing due to the '[]' in the database.

    So how to overcome this problem so that I can search string of
    [CONN-3] connectors only for field termination of 1127 cable from database.

    Many Thx,
    Cheers
    LOOI

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    sorry, i don't understand what string you wish to find

    if you wish to find exactly that string, use equal, not LIKE

    if you wish to find any string with something in square brackets at the front, try

    ... like '![%!]%' escape '!'

    otherwise, see if this helps --
    http://msdn.microsoft.com/library/de...ca-co_2f3o.asp



    rudy
    Last edited by r937; 07-11-03 at 08:42.

  3. #3
    Join Date
    Jul 2003
    Posts
    8

    "=" is not allowed when data type is text

    Sorry make u all unclear,

    Let put this way.
    I wish to find a string i.e
    [CONN-3] connectors only for field termination of 1127 cable. And this string is inside say table1 with the field (MyString) and data type is text

    when i perform a SELECT query i.e
    SELECT * FROM table1 WHERE MyString LIKE '[CONN-3] connectors only for field termination of 1127 cable'

    And it's return 0 row. I try using "=" rather than LIKE, but is not allowed because the data type is text.

    When i search at the SQL Online documentation, the eg give to me is ,
    LIKE '[M-Z]inger' searches for all names ending with the letters inger that begin with any single letter from M through Z (Ringer)..

    which mean my SELECT query won't work.


    Any idea?

    Many thx,
    Cheers,
    LOOI

    Originally posted by r937
    sorry, i don't understand what string you wish to find

    if you wish to find exactly that string, use equal, not LIKE

    if you wish to find any string with something in square brackets at the front, try

    ... like '![%!]%' escape '!'

    otherwise, see if this helps --
    http://msdn.microsoft.com/library/de...ca-co_2f3o.asp



    rudy

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    gotta use wildcards --
    Code:
    SELECT * FROM table1 
    WHERE MyString 
    LIKE '%[CONN-3] connectors only for field termination of 1127 cable%'
    rudy

  5. #5
    Join Date
    Jul 2003
    Posts
    8

    0 result return

    Hey rudy,
    I try it

    Originally posted by r937
    gotta use wildcards --
    Code:
    SELECT * FROM table1 
    WHERE MyString 
    LIKE '%[CONN-3] connectors only for field termination of 1127 cable%'
    rudy
    but still the same, return 0 row.

    Many thx,
    Cheers,
    LOOI

  6. #6
    Join Date
    Jul 2003
    Posts
    8
    Hey Rudy,

    Thx a lot I got it using ESCAPE keyword

    Many Thx
    Cheers,
    LOOI

    Originally posted by r937
    gotta use wildcards --
    Code:
    SELECT * FROM table1 
    WHERE MyString 
    LIKE '%[CONN-3] connectors only for field termination of 1127 cable%'
    rudy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •