MySQL Forums
Forum List  »  Italian

Re: Problema con query
Posted by: Alfredo Camaiti
Date: January 16, 2009 05:15PM

Ho risolto ;)
Per prima cosa ho creato una chiave UNICA con i due campi della tabella:

CREATE UNIQUE INDEX comp ON tabella (`id_user`, `data`);

Poi utilizzando questa query:

INSERT INTO session (id_user,valore,data) VALUES (4,1,CURRENT_DATE)
ON DUPLICATE KEY UPDATE valore=valore+5

Ho risolto il problema. L'accoppiata id_user - data รจ sempre unica, e quindi il comando ON DUPLICATE KEY funziona perfettamente :D

Grazie per l'indicazione, grazie alla quale ho trovato la soluzione al problema.

Alfredo

Options: ReplyQuote


Subject
Views
Written By
Posted
5169
January 15, 2009 11:52AM
3381
January 16, 2009 03:37AM
3527
January 16, 2009 01:17PM
Re: Problema con query
3477
January 16, 2009 05:15PM
3315
January 17, 2009 11:18AM


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.