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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:56:26+00:00 2026-05-13T14:56:26+00:00

I have a database which contains 5 fields, which are: name, address, idcard, town,

  • 0

I have a database which contains 5 fields, which are: name, address, idcard, town, street

I then have a PHP query which accepts one parameter. In this parameter, you can enter whatever fields you like and the results must still be accurate.

For example, if I enter john doe skate street in the search box you will get all the records whose name is John Doe and they live in the street known as Skate Street.

Also, please note that the name is stored in one field in the order SURNAME NAME (I cannot change this because this is a must so please don’t tell me that its better to change it… I know that :)). Obviously, I would like that the name can be entered in any order, be it NAME SURNAME or SURNAME NAME.

My idea is to first attach the first two entered parameters as the name. I will tell my client that the first 2 parameters must be the name and surname or surname and name. Following the name, he may then enter any of the order attributes in whatever order he likes, i.e.

These will be accepted:

name surname idcard town street
surname name idcard town street
name surname town idcard street
surname name address street idcard

These will not be accepted:

idcard town name surname street
town name surname idcard

for the simple reason that we will complicate the query too much (because of the name/surname reason, and them being in the same field)

If there is a way how the latter is possible without a lot of complications, I would like to hear it as well.

I would appreciate some help on this matter

Many thanks in advance

  • 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-13T14:56:26+00:00Added an answer on May 13, 2026 at 2:56 pm

    The kind of search you seem to be after is not really the sweet spot for RDBMSs such as MySQL. And specifying the allowable search formats is not generally good for usability, unless it’s a rather specific domain.

    Keeping it very generic, the query to search three fields for “Persons Name Fake Street” could be something like this:

    SELECT * FROM Users
    WHERE (FirstName LIKE "%Persons%"
    OR LastName LIKE "%Persons%"
    OR Address LIKE "%Persons%")
    AND (FirstName LIKE "%Name%"
    OR LastName LIKE "%Name%"
    OR Address LIKE "%Name%")
    AND (FirstName LIKE "%Fake%"
    OR LastName LIKE "%Fake%"
    OR Address LIKE "%Fake%")
    AND (FirstName LIKE "%Street%"
    OR LastName LIKE "%Street%"
    OR Address LIKE "%Street%")
    

    This should find any member who has details matching those given. But isn’t very elegant and will only get worse with longer queries and more fields. It’s also incredibly inefficient and will struggle quickly as the table gets longer – it’s unable to use indexes. It also doesn’t help you get the “best” matches at the top (if there are numerous results)

    A better solution might be to use MySQLs Full Text indexing by creating a separate table that can be searched using the full text index to find the relevant Users. I don’t know much about this solution.

    Another option may be to use an external indexing tool such as Lucene. While it adds more complexity, it allows extra functionality such as weighting of fields. So name could be seen as more important than address for example. This can also order the results in order of relevance.

    The correct solution depends on your requirements (as always) but those are some ideas that might be worth investigating.

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

Sidebar

Related Questions

I have a table Person which contains 2 fields.In my another database i have
I have one database table which contains 8 columns. One of the columns is
I have a database Student which contains about 20 tables. one of the tables
I have table in my database which has fields of ID,NAME,CONTEXT. I am showing
I have a database structure that has a Person table which contains fields such
I have a table in a database that contains two fields id name I
I have a database which contains the link to audio files. I am trying
i have a database which contains an arabic tables , i can read it
I have a database which contains picture data stored as a binary blob. The
At the moment, I have a database which contains username, password, etc. I am

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.