Jump to content

Simple problem


paul2463

Recommended Posts

hi guys I realise this might be a simple problem and the answer is staring me in the face, I can manage what i need through PHP however it would be easier for me if the data was pulled in the query. I will simplify the table makeup to try and make the problem easier. I have 1 table lets call it golfballs, it has four columns (white , orange, green, red) and each column stores the number of each colour golf ball that each golfer has. now I also have a requirement for knowing the total number of all coloured golfball the golfer has, this is dynamic data and is therefore not stored in the table but calculated, as I said I can do it through PHP by simple query and then adding all numbers together to get the total

so the query would be

$query = "SELECT `white` , `orange`, `green`, `red` FROM golfballs WHERE golfer is '$golfer'";
// then i iterate through the row and calculate the toal number of balls

 

what I would like to do is something like

$query = "SELECT `white` , `orange`, `green`, `red` SUM(`white` , `orange`, `green`, `red`) AS totalgb FROM golfballs WHERE golfer is '$golfer'";

 

many thank sin advance to all help proffered

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.