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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:34:28+00:00 2026-06-05T07:34:28+00:00

Simple to say, but I can’t find the syntax or even an example even

  • 0

Simple to say, but I can’t find the syntax or even an example even close! Assume the following tables:

Table:'Red'
Fields: id | sm | md | lg
Data:    1 | 3  | 5  | 7
         2 | 9  | 8  | 7
         3 | 2  | 4  | 6

Table:'White'
Fields: id | sm | md | lg
Data:    1 | 0  | 0  | 0
         2 | 0  | 0  | 0
         3 | 0  | 0  | 0

Table:'Blue'
Fields: id | sm | md | lg
Data:    1 | 1  | 1  | 1
         2 | 1  | 1  | 1
         3 | 1  | 1  | 1

All i want is to total everything up, but keep the rows like the following table:

Table:'Total'
Fields: id | sm | md | lg
Data:    1 |  4 | 6  | 8
         2 | 10 | 9  | 8
         3 |  3 | 5  | 7

Then create a while loop in PHP to echo back the results. Something like this:

<?php

while($row = mysql_fetch_array($get_totals))
{
echo <td>".$row[sm]."</td><td>".$row[md]."</td><td>".$row[lg]."</td>";
}

?>

I can’t figure this out. Any help? I just need a php select statement that will work here.

  • 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-05T07:34:28+00:00Added an answer on June 5, 2026 at 7:34 am

    Not tested but should work:

    SELECT id, SUM(sm) as sm, SUM(md) as md, SUM(lg) as lg FROM (
       SELECT * FROM Red
       UNION ALL
       SELECT * FROM White
       UNION ALL
       SELECT * FROM Blue
    ) AS somealias 
    GROUP BY id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure this is a very simple question, but embarrassed to say I can't
This may seem like a simple question, but I can't find the definite answer:
What I want to do seems pretty simple, but I can't find any answers
This is a simple question, and a seemingly simple task but I can't find
Okay, I know this is probably dead simple, but I can't seem to find
It seems pretty simple but I can't find a good way to do it.
I am sure this is very simple but I can't find an answer anywhere.
I thought this would be simple but I can't seem to find a variable
What I'm trying to do is relatively simple but I can't find documentation. Let's
okay, this has got to be simple - but I can't seem to find

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.