Jump to content

[SOLVED] Searching 2 columns on the same table for the same search terms


Submerged

Recommended Posts

It seems like this would be a common question, but searching through the forums hasn't turned up exactly what I'm looking for.  Basically, I have a table names "sites", and 2 of the columns in there are named "name", and "description".  I then have a query to search for a specific term.

I have the query itself down just fine, when I'm just searching the "name" column:

[code=php:0]SELECT * FROM sites WHERE name LIKE '%$term[0]%' AND name LIKE '%$term[1]%' AND category IN ('1','2','3','4','5','6','7','8','9')[/code]


Which works just fine, but I also need to it to search through the "description" category in the same way as the "name" one (which includes the neccesary "category IN" part).

I'm relatievly new to MYSQL, so I'm not sure how to process the syntax in that, but if someone could give me a hand it would be really great :)

-Alex
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.