mysqlmysql-error-1248

#1248 - Every derived table must have its own alias - can´t find the reason


I'm getting this error:

#1248 - Every derived table must have its own alias

the query is:

UPDATE rifa
SET maxRifas=(
              (SELECT maxRifas 
               FROM (SELECT * FROM rifa AS crifa)
               WHERE crifa.id=1)
              -1)
WHERE rifa.id=1;

help please.


Solution

  • Nested queries must be given an alias when used in a FROM.

    UPDATE rifa 
    SET maxRifas=
      (
          (SELECT maxRifas 
           FROM (SELECT * 
                 FROM rifa
                ) as crifa 
           WHERE crifa.id=1
          )-1
       )     
    WHERE rifa.id=1;