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

    Unhappy Unanswered: Escaping an ampersand in match against

    After trawling the web for a few hours fruitlessly trying top find the answer.

    Does anyone know how to do the following

    match(product_description) against ('+M&S* ' in boolean mode)

    where the data is stored in a database as 'M&S Sofa'.

    I do not have the rights to change the source data. I cannot use like as the above is a simple query, and the need for full text indexing is a must.

    TIA

    Paul

  2. #2
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    Does anyone know how to do the following

    match(product_description) against ('+M&S* ' in boolean mode)
    I do not have the rights to change the source data. I cannot use like as the above is a simple query, and the need for full text indexing is a must.
    ??? What does that mean??? I can only assume you are trying to get product descriptions with the string "M&S" in them?

    Code:
    SELECT
         *
    FROM
         table
    WHERE
         product_description LIKE "%M&S%"
    If that doesn't help, post back and try to explain simply what you are trying to do.

  3. #3
    Join Date
    Nov 2004
    Posts
    2
    Quote Originally Posted by jfulton
    ??? What does that mean??? I can only assume you are trying to get product descriptions with the string "M&S" in them?
    I am - however I cannot use 'like' - I have to use match against and the ampersand is being interpreted as either a logical AND or as a parameter so I need to escape the ampersand in the against clause. The example I used is extremely simplistic but should give the essence of what I am trying to do.

    Escaping a character means replacing it with an escape character so the query processor does not get confused - for example wanting to find the occurence of a directory structure you have to escape the \ by using a \\. However I cannot find how to replace the ampersand in the against clause, as it works different to the like clause. An ampersand in like does not need escaping, however in against it does.

    regards Paul

  4. #4
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    Ah sorry about that. You just introduced me to the boolean mode option. I thought you were just trying to find things like 'M&S' and didn't read that you can't use the LIKE operator .

    Aaaanyways...I thought you couldn't use match against with such short strings? If you're using longer strings, can't you encapsulate the terms in double quotes to deal with the special characters? As far as I've read it seems like this is the case?

    the ampersand is being interpreted as either a logical AND or as a parameter
    Hmmm...what is your environment? I just tried running some queries with the '&' character and they seemed fine. Without using double quotes too...Maybe it is just the length factor???

Posting Permissions

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