SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb search 3 characters at beginning of word (was "Search query")

    Another newbie question here,

    I need to search at the beginning of the word, ie. if I search for "123" I need only results that start with "123" and not those containing "123" in the middle or at the end.

    Could someone direct me to specific documentation regarding this matter or suggest a quick tip, please.

    Thanks a lot in advance.
    Last edited by andROO; Jan 17, 2006 at 08:18.

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    696
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Search the manual for LIKE predicates.

    e.g.

    Code:
    where <columnName> like '123%'

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This did the trick, thanks, swampBoogie! As a followup question:

    Would it be possible to search only by the first 3 numbers entered and ignore the rest if there are more? I mean if you enter "12345" to be searched, it should search by 123 and ignore "45"...

    Hope this makes sense.

  4. #4
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorted by using substr()


Bookmarks

Posting Permissions

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