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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:04:06+00:00 2026-05-31T21:04:06+00:00

I have a textfield which takes in full name example: michael peter johnson in

  • 0

I have a textfield which takes in full name example: michael peter johnson
in my table i have three columns firstName , middlename and lastname
I have written this query but it returns empty

SELECT firstName,middleName,lastName
FROM staff
WHERE firstName LIKE "%michael peter johnson%"
OR middleName LIKE "%michael peter johnson%"
OR lastName LIKE "%michael peter johnson%" 

if a user types in son it should display michael peter johnson, since son is contained in johnson.

thanks
my table : firstName has (michael) middleName has (peter) lastName (johnson)

  • 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-31T21:04:08+00:00Added an answer on May 31, 2026 at 9:04 pm

    You’re checking for any string that includes all of michael peter johnson in it.

    You need three separate statements, with different comparisons…

    WHERE
       firstName  Like '%michael%'
    or middleName Like '%peter%'
    or lastName   Like '%johnson%"
    

    You could reverse the logic…

    WHERE
       'michael peter johnson' LIKE '%' + firstName  +'%'
    or 'michael peter johnson' LIKE '%' + middleName +'%'
    or 'michael peter johnson' LIKE '%' + lastName   +'%'
    

    You also give an example where the search is for 'son'. Your existing code will work for that. It’s just a ‘problem’ when you compare each individual part of the name against a parameter that has all of the name.

    So, maybe you want both version together?

    WHERE
       'michael peter johnson' LIKE '%' + firstName  +'%'
    or 'michael peter johnson' LIKE '%' + middleName +'%'
    or 'michael peter johnson' LIKE '%' + lastName   +'%'
    or firstName  LIKE '%' + 'michael peter johnson' + '%'
    or middelName LIKE '%' + 'michael peter johnson' + '%'
    or lastName   LIKE '%' + 'michael peter johnson' + '%'
    

    You just need to decide exactly what behaviour you want, and then work it through.

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

Sidebar

Related Questions

I have several TextField columns on my UserProfile object which contain JSON objects. I've
I have the following plugin, which takes a partial game name, bounces it off
I have a very high-traffic table with a char(50) field which takes part in
I have a textfield which displays a result but I don't want it to
I have a textField on my stage named 'adBuy', which when clicked I want
In a SQL server database, I have a table which contains a TEXT field
I have a variable which contain the textfield value. I want to multiply that
I have the below linq query which takes a text field which may be
I have created code which takes a string from a text field and calls
Hi I have a text field which I would like to bind to a

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.