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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:12:16+00:00 2026-06-05T20:12:16+00:00

I have a table that stores data that has been entered regarding the amount

  • 0

I have a table that stores data that has been entered regarding the amount of waste put in a bin. So my table looks like this:

Material  |  Weight
===================
Paper     |  10
Plastic   |  5
Paper     |  7

As you can see, I’m going to have duplicate data in the table. At the moment I have multiple instances of different materials, and they all have different weight values attached to them.

Is it possible in PHP to get these duplicate entries, combine them in to one entry, and then display them? So the code would take the 10Kg of Paper and add it to the other instance of paper in the table (7Kg) and then output the value?

I have tried the GROUP BY in MySQL, but all that will do is combine all of the entries and give me the value of the top record, which isn’t right.

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-06-05T20:12:17+00:00Added an answer on June 5, 2026 at 8:12 pm

    Use MySql, with a SUM column. This will sum up all values for that column, for each grouping. This is assuming the weight column is just a number (10 instead of 10kg).

    SELECT 
        `material`, 
        SUM(`weight`) AS `weight` 
    FROM `material_weights` 
    GROUP BY `material`
    

    If the weight column isn’t just a number (10kg instead of 10), then there will be issues.

    If all weights are in KG, then you should just remove the ‘kg’ value from each weight, and convert the weight column from text into a numeric column.

    If there are different kinds of weights (KG, LB, G, etc), then the best way would be to have an extra field in the table, with the weight converted into KG.

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

Sidebar

Related Questions

I have a table from a vendor application that stores some xml data into
I have a table that stores user information. The table has a userid (identity)
I have mysql table that has a column that stores xml as a string.
I have a table of results that looks like this: score_id, uid, af_id, level,
I have a table that contains some sensitive data that I would like to
I have a table (MySQL) data that stores a bunch of signup information. What
I have an array of data that has been collected by iterating through an
i have a stored procedure that has to retrieve data from multiple tables something
I have a table that stores email in 3 diffrent columns name host and
I have a table that stores various clients I have done work for, separated

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.