I tried to write a procedure but when I try to run it I obtained this error:
Error Code: 1054. Unknown column 'lista1.ID' in 'where clause'
This is the routine code:
CREATE DEFINER=`root`@`%.zamberlan.local` PROCEDURE `TMTotal`()
BEGIN
    DROP temporary table if exists `lista1`;
    CREATE temporary TABLE `lista1` as
    (select 
        T.idarticolo as ID,
        avg(tempo) as TI
    from
        (select 
            idarticolo,
            ordineua,
            tempo
        From ordini 
        where tempo Is Not Null 
        group by ordineua 
        having count(ordineua) = 1) T
        group by T.idarticolo);
UPDATE
    articoli
set
    tempomediogg=lista1.TI 
where articoli.id=lista1.ID;
END
WHY?
