List:General Discussion« Previous MessageNext Message »
From:Edward Kay Date:May 10 2007 9:13am
Subject:RE: adding 3 values
View as plain text  

> -----Original Message-----
> From: ross@stripped [mailto:ross@stripped]
> Sent: 10 May 2007 10:08
> To: mysql@stripped
> Subject: adding 3 values
> 
> 
> Hi,
> 
> I have 3 integer values in the table  single_rooms, double_rooms, 
> twin _ooms but want to add them all up to do a comparison to see 
> if the combined number of rooms is less than ten.  
> 
> Ta,
> 
> R.
> 
> 

SELECT SUM(single_rooms, double_rooms, twin_rooms) from TABLE;

Or, if you want a boolean value depending if there are less than 10:

SELECT IF(SUM(single_rooms, double_rooms, twin_rooms) < 10,1,0) from TABLE;

Edward
Thread
adding 3 valuesross10 May
  • RE: adding 3 valuesEdward Kay10 May
    • RE: adding 3 valuesEdward Kay10 May
      • Re: adding 3 valuesross10 May
        • Re: adding 3 valuesPeter Brawley10 May