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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:49:26+00:00 2026-06-10T23:49:26+00:00

I have table : ========================================================== |id | before | after | freq | id_sentence

  • 0

I have table :

==========================================================
|id | before | after | freq | id_sentence | document_id  |
==========================================================
| 1 |    a   |   b   | 1    |     0       |      1       |
| 2 |    c   |   d   | 1    |     1       |      1       |
| 3 |    e   |   f   | 1    |     1       |      1       |
| 4 |    g   |   h   | 2    |     0       |      2       |
==========================================================

I want to get the number of data depend on the id_sentence and freq so the result must be 1 2 1
here’s the code :

$query = mysql_query("SELECT freq FROM tb where document_id='$doc_id' ");
    while ($row = mysql_fetch_array($query)) {
        $stem_freq = $row['freq'];
        $total = $total+$stem_freq;

but the result is still wrong. please, help me.. thank you 🙂

  • 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-10T23:49:28+00:00Added an answer on June 10, 2026 at 11:49 pm

    If I understand your question, you are trying the calculate the sum of freq for each distinct id_sentence for a particular document_id.

    Try the following SQL:

    SELECT id_sentence, SUM(freq) as freq FROM tb WHERE document_id = 1 GROUP BY(id_sentence)
    

    The result will be rows of data with the id_sentence and corresponding total freq. No need to manually sum things up afterwards.

    See this SQL Fiddle: http://sqlfiddle.com/#!2/691ed/8

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

Sidebar

Related Questions

I have a trigger that check data before insert to another table IF NOT
I have a user-defined table type. I want to check it's existence before editing
i want to find a number of clients from certain dates before and after
I want to clean up some data in a table before putting in a
I know that I should have schema of a table before calling NewRow method
I have a table trigger like below: CREATE OR REPLACE TRIGGER PAT_BUR_DOB_TRG BEFORE UPDATE
In iOS apps, we have to register nib files with our table view before
I have to insert the values in the table named First, but before inserting
I used to have tables before to display the content and people here advised
I have table and this table contain result column with some entries. I just

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.