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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:20:24+00:00 2026-05-23T21:20:24+00:00

I have a table of keywords with an integer weight associated with it. In

  • 0

I have a table of keywords with an integer weight associated with it. In another table I have a table of texts. I would like to compute the value of each text by finding the keywords and summing the weights in the text. Is there a way to do this entirely in SQL?

  • 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-23T21:20:26+00:00Added an answer on May 23, 2026 at 9:20 pm

    If you represent your texts as

    | text_id | count | word      |
    |---------+-------+-----------|
    |       1 |     1 | nice      |
    |       1 |     2 | weather   |
    |       1 |     3 | no?       |
    |       2 |     1 | Mayer     |
    |       2 |     2 | Hawthorne |
    |       2 |     3 | has       |
    |       2 |     4 | soul      |
    

    where text with ID 1 is “nice weather no?”, for example, you can calculate the text scores using the keyword table

    | keyword   | weight |
    |-----------+--------|
    | weather   |      2 |
    | nice      |      3 |
    | Hawthorne |     10 |
    | soul      |      5 |
    

    with

    SELECT t.text_id AS text_id, SUM(k.weight) AS score
    FROM texts t
    LEFT JOIN keywords k
    ON k.keyword == t.word
    GROUP BY t.text_id;
    

    resulting in

    | text_id | score |
    |---------+-------|
    |       1 |     5 |
    |       2 |    15 |
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Keywords table with the fields KeywordsEn and KeywordsFr. I have another
I have keywords in table (for example texts table, key column). How to get
I have a table in MySql with a list of keywords. Each keyword was
I have a table named KEYWORDS with a column named ENTRY of VARCHAR(10). Would
I have a table in a database with a structure like this Keywords id
I have two tables that are related via a mapping table: keywords titles I
I have this XML in a column in my table: <keywords> <keyword name=First Name
I have table with 50 entries (users with such details like Name Surname Location
I have table with some fields that the value will be 1 0. This
I have two tables. Lets say they look like this Table Sports: Column 1:

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.