Need help on simple pattern matching searching

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Henry

    Need help on simple pattern matching searching

    I have a table that stores a list of zip codes using a varchar column type,
    and I need to perform some string prefix pattern matching search. Let's say
    that I have the columns:
    94000-1235
    94001
    94100

    If I run a pattern matching search for the string "940", then I should get
    the top two rows of data back. If I run a pattern matching search for the
    string "94", then I should get all the three rows of data back.
    How can I do that in MySQL? I dont' need to do full-text search for this
    prefix pattern matching search, do I? Thanks.


  • Wouter

    #2
    Re: Need help on simple pattern matching searching


    SELECT * FROM database WHERE col LIKE '940%'



    "Henry" <hjyu20042003-free@yahoo.com> wrote in message
    news:eYZld.4381 8$QJ3.18394@new ssvr21.news.pro digy.com...
    :I have a table that stores a list of zip codes using a varchar column type,
    : and I need to perform some string prefix pattern matching search. Let's
    say
    : that I have the columns:
    : 94000-1235
    : 94001
    : 94100
    :
    : If I run a pattern matching search for the string "940", then I should get
    : the top two rows of data back. If I run a pattern matching search for the
    : string "94", then I should get all the three rows of data back.
    : How can I do that in MySQL? I dont' need to do full-text search for this
    : prefix pattern matching search, do I? Thanks.
    :
    :


    Comment

    Working...