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

Ask A Question

Stats

  • Questions 268k
  • Answers 268k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's not so much about how the app behaves on… May 13, 2026 at 1:10 pm
  • Editorial Team
    Editorial Team added an answer My mistake - I was setting IFS to "\n" only… May 13, 2026 at 1:10 pm
  • Editorial Team
    Editorial Team added an answer As has been said, source control is a definite. It… May 13, 2026 at 1:10 pm

Related Questions

I have to hack a content management system to support fulltext search for a
I am a fairly new MySQL developer and am starting on a project that
I'm attempting to add searching support for my PHP web app using MySQL's FULLTEXT
I'm working with a table in MySQL that contains the following columns: id, january,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.