Tag: MySQL

  • Modificare l’ora di un campo DATETIME in MySQL

    A volte capita di lavorare su codice che non è possibile modificare e quindi dover fare i salti mortali per ottenere quella che in realtà è una cosa semplicissima. Nello specifico avevo bisogno di modificare un campo DATE di una tabella in un campo DATETIME, dato che per l’applicazione era necessario memorizzare anche l’ora precisa […]

  • Multiple Sum with different conditions in MySQL

    Today I was working on my last project that involves some statistics on data. I had a table like this: I needed the daily, monthly and yearly sum of the value field. The simplest approach was to have three different queries to retrieve the needed values: –day SELECT SUM(value) FROM table WHERE DATE(time)=CURDATE(); — month […]