Results 1 to 4 of 4

Thread: MySQL Question

  1. #1
    Join Date
    Sep 2002
    Boston, MA

    MySQL Question

    I have a table where one of the fields has a description that is often a few sentences long. I would like to be able to search this field, but I'm running into a slight problem. I wonder if there's a simple workaround.

    Let's say for example the field name is description and some values are:

    "indoor and outdoor sports equipment"
    "cool doorbells"

    Now basically, I would like to devise a search where if a user is looking for the term "door" it only gives results where values contain words that only begin w/ the search term. So for example:

    select * from table where desc like "[wordbeginswith]door"

    Or some way of doing this without having to parse the results w/ some kind of extra php functions. I would like this statement to only return the entry whose description value is "cool doorbells" and not the others.

    I hope I'm being clear w/ what I'm looking to do. Any help would be greatly appreciated!

  2. #2
    Join Date
    Dec 2003

  3. #3
    Join Date
    Apr 2004
    Originally posted by monaghan
    have you tried

    LIKE "% door%" ?
    That's the way I'd do it - but it wouldn't work if the word was first in the sentence

  4. #4
    Join Date
    Apr 2004
    East Anglia, UK
    I'd recommend taking a look at MySQL's REGEXP operator.

Posting Permissions

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