UPDATE ost_timeblock
SET
timeblock_due_date=DATE(timeblock_next_update),
timeblock_next_update=DATE_ADD(NOW(),INTERVAL timeblock_recurrence_time **timeblock_recurrence_unit**)
WHERE timeblock_recurrence=1
AND timeblock_complete=0
AND timeblock_next_update=FROM_UNIXTIME(1337662800)
当我使用手动日或月作为timeblock_recurrence_unit
它工作正常。查询中的变量
timeblock_recurrence_unit = enum(day,month,year)
我想在上面的粗体字位置
的timeblock_recurrence_unit
值是否有任何方式的情况下做到这一点。
If timeblock_recurrence_unit = 'day' then
timeblock_next_update=DATE_ADD(NOW(),INTERVAL timeblock_recurrence_time day)
If timeblock_recurrence_unit = 'month' then
timeblock_next_update=DATE_ADD(NOW(),INTERVAL timeblock_recurrence_time month)
请格式化你的查询,它适合在几行 – Sebas
我指这位议员[本](http://stackoverflow.com/questions/6749892/sql-use-column-value-作为关键字,在查询字符串)。不幸的是,这是不可能的。抱歉。 – DaveRandom