SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    On search with LIKE

    've been working on an app that involves searching the database, im using LIKE, something like:

    Code:
    "select * from news where headline like '%$search-term%' or content like '%$search-term%' "
    I found out that LIKE is only good for one-word searches.
    --Returns results for good day but not for day good- though good and day exist in the database (but not in that order
    and I didnt surround the search term with quotes).
    -Also if searched for good day will produce results but search for "good day" will not produce results.Generally, quoted
    terms do not produce any results.

    How do I break up the search to make the script search for individual words
    in the search term in any order of appearance and to search for quoted terms or is there a more professional searh method other than LIKE?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,017
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by tentim View Post
    How do I break up the search to make the script search for individual words
    with your front-end application

    suggest you ask a moderator to move this thread to the appropriate forum (php? asp? java?)
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •