mysql - Sum values of a single row? -


I have a MySQL query that returns a line which is a series of 1s and 0s This progress bar is for pointer I have a short code for this code, but I tried to submit the values ​​in a query and I realized that I can not use SUM () because they are multiple columns but only one line

< P> Is there any way I can add this query automatically? This is like this:

  item_1 | Item_2 | Item_3 | Item_4 ------- + -------- + -------- + -------- 1 | 1 | 0 | 0  

Edit: I forgot to mention, item_1 and no further simple field values, but each one has an expression, such as < Code> if selected (field_1 = 1 and field_2 is not zero, 0, 1) Atom item ... ... , it seems that I have a nested query:

  SELECT (item_1 + item_2 ...) (select if field_1 = y and field_2 is not zero, 1, 0) ASI item_1 ...) as nickname  

right is?

  select item items item_1 + item_2 + item_3 + Item_4um ItemSum MyTable  

If there can be zero values, then you have to handle them like this:

  ifnull (item_1, 0) + ifnull ( Item_2, 0) + ifnull (item_3, 0) Select + Ifnull (item_4, 0) from MySQL as ItemSum  

Comments