I have some problem with UPDATE statement with 2 Where clause.
I want update StatoBloccato,Aperto,OrarioApertura,OrarioChiusura only day called Lun and IDRoom = 1
But this UPDATE change values for all days.
UPDATE room
INNER JOIN giorni ON (room.IDRoom = giorni.FKRoom)
SET StatoBloccato = false,
Aperto = true,
OrarioApertura = '09:00:00',
OrarioChiusura = '18:00:00'
WHERE room.IDRoom = 1 AND Nome LIKE 'Lun%';
There are 2 tables: Room , Giorni.
Here is SQLFiddle
This appears to work when I try it here.
The specific query is:
UPDATE room r JOIN
giorni g
ON r.IDRoom = g.FKRoom
SET r.StatoBloccato = false,
g.Aperto = true,
g.OrarioApertura = '09:00:00',
g.OrarioChiusura = '18:00:00'
WHERE r.IDRoom = 1 AND g.Nome LIKE 'Lun%';
Although this should be equivalent to your query, this uses qualifies all column names, so it is clear what table they are coming from.