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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:18:39+00:00 2026-05-15T05:18:39+00:00

I’m trying to implement a facebook search in my system (auto suggest while typing).

  • 0

I’m trying to implement a facebook search in my system (auto suggest while typing).
I’ve managed to code all the ajax stuff, but I’m not sure how to query the database.

I’ve created a table called People which contains the fields: ID, FirstName, LastName, MiddleName, Email.
I’ve also created a FTS-index on all those fields.

I want to create a stored procedure that will get as a parameter the text inserted in the query box and returns the suggestions.

For example, When I will write in the textbox the query “Joh Do”
It will translate to the query:

select * from People where contains(*, '"Joh*"') and contains(*, '"Do*"')

Is there a way to do that in stored procedure?

P.S
I’ve tried to use the syntax

select * from People where contains(*,'"Joh*" and "Do*"')

but it didn’t returned the expected results, probably because it needs to search the words on different fields. Is there a way to fix that?

Thanks.

  • 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-15T05:18:40+00:00Added an answer on May 15, 2026 at 5:18 am

    Try

    select   *
    from     People
    where    (FirstName  Like '%'+ @FirstName  + '%') and
             (MiddleName Like '%'+ @MiddleName + '%') and
             (LastName   Like '%'+ @LastName   + '%')
    

    Also you may want to restrict the results to only return a maximum of say 10 by using:

    select top 10
    

    EDIT 1:

    OK I now understand the problem better. I would use dynamic sql thus:

    First create a split function e.g. Example Split function using XML trick

    Then use dynamic sql:

    declare @tstr varchar (500)
    
    set @tstr = ''
    
    select  @tstr =@tstr + ' Contains(*, ''"'+ val + '*")' + ' and '
    from  dbo.split(@SearchStr, ' ') 
    
    
    set @tstr =  left(@tstr,len(@tstr)-4)
    
    select @tstr
    Declare @dsql as varchar(500)
    
    set @dsql = 'select * from People where '+ @tstr
    
    exec (@dsql)
    

    Also please note as per Remus, be aware of SQL Injections, the use of sp_executesql (instead of EXEC) would be better.

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

Sidebar

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.