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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:16:17+00:00 2026-05-26T04:16:17+00:00

I have a form with an input box where user can specify their names,

  • 0

I have a form with an input box where user can specify their names, names can be two or more words eg John Smith or John Michael Smith.

I need to write a query which would return the records including ALL words in the submitted name. So query will return records which has all those name words but can have different order.

For example, if search string is John Michael Smith, query should be able to return records with names such as John Smith Michael, Michael Smith John, Smith John Michael or other combination with all those words there. As can be seen return only records which still has all words in name field but can have different order. It should not however return results which do not contain a name part for example John Michael should not be returned since it is missing Smith.

I can’t figure out how to write a query for such requirement that I have. Please help.


Update

The answers provided so far return even the records that match John Michael also. I tried answers of @Marco, @abesto and @Eddie.

The problem still persists 🙁

  • 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-26T04:16:18+00:00Added an answer on May 26, 2026 at 4:16 am

    You could try a fulltext search:

    SELECT * FROM table WHERE MATCH (name)
    AGAINST ('+part1 +part2 +part3' IN BOOLEAN MODE);
    

    In this solution, ‘+part1 +part2 +part3’ would be generated in PHP.

    See the MySQL docs

    mysql> select * from sof;
    +--------------------+
    | n                  |
    +--------------------+
    | John               |
    | Smith              |
    | Smith John         |
    | Smith John Michael |
    | John               |
    +--------------------+
    5 rows in set (0.00 sec)
    
    mysql> SELECT * FROM sof WHERE MATCH(n) AGAINST('+John +Smith +Michael' IN BOOLEAN MODE);
    +--------------------+
    | n                  |
    +--------------------+
    | Smith John Michael |
    +--------------------+
    1 row in set (0.00 sec)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with an input box where the user can specify their
I have an input form with two textareas allowing a user to type in
id like to have an input box that a user can enter a search
i have one form which have some input box and some select box. i
I have a form in a .html files where input/select box looks like this
I have... a dynamic populated select box several input boxes a submit button form
I have form with one input for email and two submit buttons to subscribe
I have a requirement whereby a user can specify a variable number of user-defined
I have an HTML form that a user can add an arbitrary amount of
I have a form where users can introduce google maps urls to specify the

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.