Average value of a row in MySQL I have a row which primary key value is 4 and there are another 8 values.
Those are 45  78 89 54 98  14  19  70. I want to select the average value, ie 58.37 from this row. How do I do this ? 
The avg() function takes one argument only but i need to send 8 arguments.
My table picture is
There is a rather simpler solution. (Using information_schema can be dangerous, if there are thousands of tables in it and it can be slow at time)

I propose to use an actual function. The goal is to do a pivotal query (convert col to rows). This can be accomplish using UNION ALL.
The PK of the table in question is passed to the function allowing it to calculate and return the Average. 

The beauty about this is you can extend the function and do 95 Percentile and other type of Stats. You can use that function like other functions.

If a new column is added, all you need to do is add that column to the function.
I think it's easier then to have to exclude the column you don't want. 

CREATE FUNCTION `row_avg`(p_pk int ) RETURNS decimal(16,2)
BEGIN

DECLARE p_output decimal(16,2);

 select avg(A.rate) into  p_output 
 from (

select rate1 as 'rate' from rating where id = p_pk
union all
select rate2 as 'rate' from rating where id = p_pk
union all
select rate3 as 'rate' from rating where id = p_pk
union all
select rate4 as 'rate' from rating where id = p_pk
union all
select rate5 as 'rate' from rating where id = p_pk
union all
select rate6 as 'rate' from rating where id = p_pk
union all
select rate7 as 'rate' from rating where id = p_pk
) as A ;


  RETURN p_output;

END


table:

CREATE TABLE `rating` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `role` int(11) DEFAULT NULL,
  `student_name` varchar(10) DEFAULT NULL,
  `rate1` tinyint(4) DEFAULT NULL,
  `rate2` tinyint(4) DEFAULT NULL,
  `rate3` tinyint(4) DEFAULT NULL,
  `rate4` tinyint(4) DEFAULT NULL,
  `rate5` tinyint(4) DEFAULT NULL,
  `rate6` tinyint(4) DEFAULT NULL,
  `rate7` tinyint(4) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;


Usage: 

select row_avg(id) from test.rating ;
select row_avg(id) from test.rating where id  =3 ;


Enjoy !