gaurav gaurav - 1 year ago 71
MySQL Question

mysql select records with sum of two column less than a column

i am trying to write query which can select all records with below conditions
sum of column a and b to be less than c
i wrote below code but it does not works :

SELECT *,(`a` +`b`) as newfinal,c FROM mytable WHERE newfinal<c

SELECT * FROM mytable WHERE (`a` +`b`) < c

i am stuck with it can u please help me with my query

Answer Source

Just tried this on my stats database - works for me

SELECT * FROM `stats` WHERE (athomegoalswon +athomegoalslost) < yellowcards
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download