Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Posts
    434
    Thanks
    7
    Thanked 3 Times in 3 Posts

    How can I search multiple fields for a LIKE %phrase%

    I have over 30 fields in my table and wish to find out how I allow my search page to perform a search all on fields nistead of having a very long query with each and every field in it.

    Can this be done? if so how ?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Consider adding a combined fulltext index on all the columns instead of using LIKE. See http://devzone.zend.com/article/1304 to know more
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Actually searching your table with LIKE '%searchterm%' is the worst way you can search your table. Any search beginning with the wild card % means that a table scan will be used and no index can be used to speed up your query.


  •  

    Posting Permissions

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