[solved] math in the query

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

[solved] math in the query

Post by magicrobotmonkey »

I have an sql table with a bunch of fields and I only want to return a result if they sum to 0. this is what I have:

Code: Select all

SELECT report.A1 + report.B1 + report.C1 + report.A2 + report.B2 + report.C2 + report.A3 + report.B3 + report.C3 AS 'Total Lives'
FROM `report` 
WHERE 'Total Lives' > 0
I know the math is working because i can just run the query and Total Lives is right. If I go 'Total Lives' = 0 it returns all results. I'm not exaclty sure whats going on here. Any ideas?
Last edited by magicrobotmonkey on Fri May 28, 2004 8:05 am, edited 1 time in total.
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

never mind, got 'im:

Code: Select all

SELECT report.A1 + report.B1 + report.C1 + report.A2 + report.B2 + report.C2 + report.A3 + report.B3 + report.C3 AS Total
FROM `report` 
HAVING Total > 0 LIMIT 0 , 30
Post Reply