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

  • SEARCH
  • Home
  • 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 4332302
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:14:13+00:00 2026-05-21T10:14:13+00:00

i have a question i do a full text search on my site and

  • 0

i have a question i do a full text search on my site and want exclude some results here is the code i use

SELECT *, MATCH(p_title, p_desc) AGAINST ('".$string."') AS score 
FROM posts 
WHERE MATCH(p_title, p_desc) AGAINST ('".$string."') 
ORDER BY score DESC LIMIT 12

Now when I add for example WHERE id != 1 AND WHERE test != 1 to end of SELECT
this does not work, i googled but didn’t find anything related to this. Is this at all possible?

I found a way with php

if($id != $list['id'] AND $list['test'] != 1) { 
// CODE
}

But this is not really what I want.
Thanks for help

  • 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-21T10:14:14+00:00Added an answer on May 21, 2026 at 10:14 am

    If you change

    SELECT *, MATCH(p_title, p_desc) AGAINST ('".$string."') AS score     
    FROM posts 
    WHERE MATCH(p_title, p_desc) AGAINST ('".$string."') 
    ORDER BY score DESC LIMIT 12
    

    To:

    SELECT *, MATCH(p_title, p_desc) AGAINST ('".$string."') AS score     
    FROM posts 
    WHERE MATCH(p_title, p_desc) AGAINST ('".$string."') 
      AND (id <> 1) AND (test <> 1)
    ORDER BY score DESC LIMIT 12
    

    It should work, of course you can’t add an extra WHERE clause after the first one.
    If you want to add extra items to filter on then you need to use AND‘s.

    Also note that doing a SELECT * will slow your query way down.
    Better list only the fields that you want to list, that will make your query much faster.
    Make sure you have an index on p_title and p_desc to keep the speed acceptable.

    If you want the search to be smarter and also return items related to $string you can change the code to:

    SELECT *, MATCH(p_title, p_desc) AGAINST ('".$string."') AS score     
    FROM posts 
    WHERE MATCH(p_title, p_desc) AGAINST ('".$string."' WITH QUERY EXPANSION) 
      AND (id <> 1) AND (test <> 1)
    ORDER BY score DESC LIMIT 12
    

    This will let MySQL do a second pass where terms in the found in the first pass are used to find extra items that do not match against $string, but that do match against the data found in the first pass.

    See: http://dev.mysql.com/doc/refman/5.5/en/fulltext-query-expansion.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use the Hibernate Search full text search capabilities. I have a
Have a question about full text search. I have a query that works, but
I have written a query which will perform Full Text search using full search
I have the following code, thanks to another SO question/answer: page = agent.page.search(table tbody
I'm new to free-text search, so pardon the newbie question. Suppose I have the
I have the following query, which performs a full-text search (CONTAINSTABLE) on the Products
I have three tables in mysql which have full text search enabled: title (title,
I'm trying to work out some of the finer details of the Full-Text Search
We use Lucene.NET to implement a full text search on a clients website. The
I have question regarding the use of function parameters. In the past I have

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.