Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4059220
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:10:49+00:00 2026-05-20T15:10:49+00:00

I have a MySQL table (table1) with following fields… id, title, description, detail, category,

  • 0

I have a MySQL table (table1) with following fields…

id, title, description, detail, category, status

What I am trying to do is searching these fields with regular php search query… My query for now is…

$q = mysql_query("SELECT * FROM table1 WHERE title LIKE '%$q%' OR description LIKE '%$q%' OR detail LIKE '%$q%' AND category='$cateid' AND status='1' ORDER BY id DESC LIMIT 10");

Where $q is my search string, $cateid is my category id and status is On/Off (Active/Inactive)

Now if get results with this query I got 5 results while I have query string = foo and it only exists in one entry not 5… And also it is showing me the rows with status=’0′
When I change my query to

$q = mysql_query("SELECT * FROM table1 WHERE title LIKE '%$q%' AND category='$cateid' AND status='1' ORDER BY id DESC LIMIT 10");

It gives me correct results…
But I also want to match my query string to description and detail fields respectively.
Please help me out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:10:50+00:00Added an answer on May 20, 2026 at 3:10 pm

    You need to put parentheses () around all the OR conditions

    SELECT * FROM table1
      WHERE (title LIKE '%$q%' OR description LIKE '%$q%' OR detail LIKE '%$q%')
        AND category='$cateid' AND status='1' ORDER BY id DESC LIMIT 10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do the following in MySQL: SELECT DISTINCT field FROM table WHERE
I have the following table: Table Account{ [...] email varchar(100), [...] } and a
Suppose I have the following table house: House: id name cityID Where cityID refers
I have an array, $scans. I want to query MySQL with all the values
Do Fields after ORDER BY or WHERE might have index (PRIMARY, UNIQUE, INDEX) in
I'm currently debugging a huge MySql call which joins a large amount of tables
i want to make my table can filtering in each column. i get client
I was wondering what would be a good way to accomplish the following using
Here's how Paul Graham describes the ranking algorithm for Hacker News : News.YC's is
I am not totally sure I am naming this right, but please bear with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.