SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Help on a query

  1. #1
    SitePoint Addict
    Join Date
    Oct 2002
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Help on a query

    Hello,

    I am building an e-commerce site for first edition books.
    I have a search field which will allow the customer to enter a title or author and then search for matching results.

    My database has a field for titile, author firstname, and author surname.

    The query at the moment is
    "select * from books where Live = 'Y' AND (Title like '%".$searchterm."%' OR Author_Firstname like '%".$searchterm."%' OR Author_Surname like '%".$searchterm."%')"

    This works fine when the customer enters a title or just a surname but if they enter both names then this causes a problem.

    Is there any way of getting around this...
    Eternity

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    getting around this? lots of ways

    write some code that pulls apart the user's entry and generates the WHERE clause elements on each word

    or, give the user three separate fields to enter title/fname/lname


    rudy


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
  •