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 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    36
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Searching a database via keyword(s)

    Hi

    On the site I'm building I want users to be able to search user posts, which I have stored in a mysql table. So if a user searches for the keyword tree (for example), I want it to return every user post that contains the word tree.

    I just can't wrap my head around how to do this, I imagine there is some sort of function that can help me acheive this, I just don't know of it. I do not want code, I just want someone to point me in the right direction. Thank you

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,965
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    Code:
    SELECT list, of, fields FROM table WHERE someField LIKE '%tree%' OR someOtherField LIKE '%tree%'
    Fair warning: It will be slow slow slow on a large table.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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