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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:53:55+00:00 2026-06-16T00:53:55+00:00

I need a SQL query to get the common words only between two sentences.

  • 0

I need a SQL query to get the common words only between two sentences. For example:

Sentence 1: This site is very helpful

Sentence 2: I need a helpful site

The result should be: site helpful

Also, if I need to compare sentence 1 to table field records to get the record that contains most common words to sentence 1, what can I do?

  • 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-06-16T00:53:57+00:00Added an answer on June 16, 2026 at 12:53 am

    You question title says MSQL, so I’m taking your question as a Sql Server question.

    1. Split function

    Depending on SQL Server version/Server Configuration, you’ll need a split function that can split a string on a delimiter of choice. Here’s such a function.

    CREATE FUNCTION [dbo].[fnSplit](@data NVARCHAR(MAX), @delimiter NVARCHAR(5))
    RETURNS @t TABLE (rowNum int IDENTITY(1,1), data NVARCHAR(max), descriptor varchar(255) NULL)
    AS
    BEGIN
    
        DECLARE @textXML XML;
        SELECT    @textXML = CAST('<d>' + REPLACE(@data, @delimiter, '</d><d>') + '</d>' AS XML);
    
        INSERT INTO @t(data)
        SELECT  RTRIM(LTRIM(T.split.value('.', 'nvarchar(max)'))) AS data
        FROM    @textXML.nodes('/d') T(split)
    
        RETURN
    END
    
    1. Query for common words using split function (there are quite a few ways to do this, here’s one).

      SELECT sentence1.data
      FROM dbo.fnSplit('This site is very helpful',' ') sentence1
      INNER JOIN dbo.fnSplit('I need a helpful site',' ') sentence2 ON sentence1.data = sentence2.data
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to execute a SQL Query between two databases. Example: SELECT * from
I need to write a SQL query which will get me those rows from
i have a problem with sql query. I need to get list of users.
I need to write a query on SQL server to get the list of
I have an SQL query I get from a configuration file, this query usually
This is a very very important sql query after which my whole website is
I have a VehicleData table. Need to write SQL query to get row with
I need to get View SQL Query to display it in some text box
I need a way to get true-false reply from SQL query that say to
I work on AI chat bot. I need sql query to select a single

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.