gaurav gaurav - 2 months ago 10
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

Just tried this on my stats database - works for me

SELECT * FROM `stats` WHERE (athomegoalswon +athomegoalslost) < yellowcards
Comments