MySQL Forums
Forum List  »  Italian

UPDATE e SELECT SUM
Posted by: Mauro Rinaldi
Date: April 05, 2015 03:03PM

Salve a tutti, sono un neofita di MySQL e ho il seguente problema.

Vorrei inserire in un campo di una tabella esistente il risultato della seguente query:

SELECT SUM(valore) FROM `voti` GROUP BY IdBrano;

praticamente il risultato della query è il punteggio (dato dalla somma dei voti) ottenuto da ciascun brano.
Ho cercato di inserirlo nell'omonimo campo 'punteggio' all'interno della tabella 'brani'in questo modo:

UPDATE brani SET punteggio =(SELECT SUM(valore) FROM `voti` GROUP BY IdBrano) WHERE brani.idBrano = `idBrano`;

phpMyAdmin mi risponde con questo messaggio d'errore:

#1242 - Subquery returns more than 1 row

Cosa sto sbagliando?
Grazie in anticipo a chi mi vorrà rispondere

Options: ReplyQuote


Subject
Views
Written By
Posted
UPDATE e SELECT SUM
2327
April 05, 2015 03:03PM
1032
April 05, 2015 03:42PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.