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

  • Home
  • SEARCH
  • 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 6178449
In Process

The Archive Base Latest Questions

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

I am solving in these days following situation: In my DB table I have

  • 0

I am solving in these days following situation:
In my DB table I have columns for name and surname.

On my page I have input for searching people, and I am struggling with a problem, how to search the name in database that is stored in two columns and I have the name as string ("Joe Green").

For example, in database I have followings:

Joe New
Joe Blue
Joe Green
Joe Francois Green

What could be the best way, how this problem to solve? I am currently working with MySQL database and Rails 3.

EDIT: Thank you guys for you replies, but I don’t know, how to make the query in Rails 3 notation, is it possible to use “concat”?

  • 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-24T00:27:31+00:00Added an answer on May 24, 2026 at 12:27 am

    if your database table engine is myISAM then use FULLTEXT search

    first create FULLTEXT index by

    CREATE FULLTEXT INDEX fx_name ON pages (name, surname)
    

    then use below query to retrieve required data

    SELECT  *
    FROM    table
    WHERE   MATCH(name,surname) AGAINST ('keyword' IN BOOLEAN MODE)
    

    update

    alternative:use CONCAT

    first create index

    CREATE INDEX users_firstandlast ON users(name, surname);
    

    option1: repeat the CONCAT in your WHERE clause (because AS doesn’t create a name you can use in the WHERE clause):

    SELECT CONCAT(name, ' ', surname) as fullname 
    FROM users 
    WHERE CONCAT(name, ' ', surname) LIKE '%joe green%';
    

    option 2:

    SELECT CONCAT(name, ' ', surname) as fullname 
    FROM users 
    WHERE name LIKE '%joegreen%' or surname LIKE '%joegreen%';
    

    More information

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

Sidebar

Related Questions

I am solving following situation - I have in table in database data and
These days I have learned some basic usage of C#. I think that because
These days I'm solving Project Euler problems in Erlang. Since I'm a C++ programmer
I am a newbie for solving these kind of problems. I need to extract
I have a trouble solving out this fiddle. When i put limits i am
I need some help solving some compile errors. I was following a tutorial (at
I have more of a 'problem solving' question than a syntax related problem. Briefly,
There is a lot of buzz these days about not using locks and using
okay I have an equivalence that I have to prove. these equivalences use biconditionals
I am solving my C assignment in Xcode and in that program i have

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.