SQL Server Performance

How could I write a sql query for search bar returning records with the most key words.

Discussion in 'ALL SQL SERVER QUESTIONS' started by Antonio Benildus Muerling, Aug 15, 2012.

  1. Good afternoon my excellent members, would straight away come to the scene without wasting a time.

    Scenario, if I had put basic acounting, in the search bar, how would I be able to get records which have the most keywords of basic accounting on top, then returning records which have only basic, then returning records which have accounting after.

    Thanks a million in reading my post.

    Thank You.

    AB
  2. FrankKalis Moderator

    I believe you're not gonna get this with some build-in logic all in just one query, although it might be possible with full-text, but I'm not familiar with that.

    Having that said, not sure if this is practical at all, but you could first get all rows that have LIKE '%basic accounting%' and UNION this with LIKE '%basic%' and UNION those with LIKE '%accounting%'. Your application would have to split the search string and then send in a query for each of the items of that split operation and append it to the search results. However, I don't think you will get good performance out of it.

Share This Page