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 472811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:07:27+00:00 2026-05-13T00:07:27+00:00

In mysql boolean match, if no operators are present, OR is implied. If you

  • 0

In mysql boolean match, if no operators are present, OR is implied. If you want AND, you need to add + to each keywords.

So query “word1 word2” is equal to “word1 OR word2”, “+word1 +word2” is equal to “word1 AND word2”

I don’t want users to have to enter + before each keyword, what are my options?

Suggested option 1: Is there something in my.conf I can change to set the defaults (I didn’t find anything)

Suggested option 2: parse the query and manually add + to each word. Any simple code for this you can share?

The problem with this is if the user adds “quotes” or operators (+-*<>) etc. it breaks my parsing code.

  • 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-13T00:07:28+00:00Added an answer on May 13, 2026 at 12:07 am

    I went with second suggestions on my site.

    Simple one liner to add + before each word if you deal only with words, (not with quoted strings)

    $q = implode(' ', array_map(create_function('$a', 'return "+".$a;'), preg_split('`\\s+`', $q))))
    

    or even simpler regex replace doing the same:

    echo preg_replace('`(\\W|^)\\w`', '\\1+\\2', $q);
    

    if you have not only single words but also quoted phrases to search this should add + before each single unquoted word and each quoted string

    echo preg_replace('`(\\s|^)(\\w|"[^"]+")`', '\\1+\\2', $q);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysql query as follows: SELECT *, MATCH(songtitle) AGAINST('{keyword}') as Relevance FROM
I have a mysql query in php, using match / against to filter results.
my SQL query SELECT keyword FROM table WHERE MATCH (keyword) AGAINST ('eco*' IN BOOLEAN
i am unable to add a Boolean value in Mysql how can i do
Since MySQL doesn't seem to have any 'boolean' data type, which data type do
I need to query the table for all but keyword. Using just - doesn't
I've found boolean mode of MySQL full text search useful, however there are a
I'm using this query to perform a full text search on a MySQL database:
What column type is best to use in a MySQL database for boolean values?
MySQL uses TinyINT to serve as a boolean field. Given the possible options of

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.