我有absen
表格,其中包含
我查询它,
SELECT count( tgl ) AS total, absen.id, absen.status, absen.kondisi,
CASE WHEN (weekday( tgl ) <=3) THEN date( tgl + INTERVAL( 3 - weekday( tgl ) ) DAY )
ELSE date( tgl + INTERVAL( 3 +7 - weekday( tgl ) ) DAY )
END AS tglitung
FROM absen
WHERE absen.status = 'm'
GROUP BY absen.id, tglitung
结果为
我希望在SET kondisi='yes'
GROUP BY absen.id='15' AND tglitung='2016-01-14'
如何使用像这样的情况设置更新?
答案 0 :(得分:1)
试试这个:
UPDATE absen SET kondisi = 'yes'
WHERE id = 15
AND (CASE WHEN (WEEKDAY( tgl ) <=3) THEN DATE( tgl + INTERVAL( 3 - WEEKDAY( tgl ) ) DAY )
ELSE DATE( tgl + INTERVAL( 3 +7 - WEEKDAY( tgl ) ) DAY )
END) = '2016-01-14';