This topic is locked

What Is Wrong With This, Help!

12/14/2005 3:38:43 AM
PHPRunner General questions
D
defcon2000 author

Hello,
Pls tell me what is wrong with my statement:
UPDATE reminder

set reminderdate = (IF (status = 'Open' and reminded = 'Y'

and autoclose = 'Y' and recur = 'Y',

ADDDATE(reminderdate, INTERVAL occurence occurencetype), reminderdate))
occurencetype can be "DAY", "MONTH" or "YEAR" and stored as a VARCHAR.

occurence can be 1,2,3,6,7,10, etc ... as an integer.
If I do the following for example, it works
----------------------------------------------------------------------

UPDATE reminder

set reminderdate = (IF (status = 'Open' and reminded = 'Y'

and autoclose = 'Y' and recur = 'Y',

ADDDATE(reminderdate, INTERVAL occurence DAY), reminderdate))

----------------------------------------------------------------------
Thanks for your help.
Rgds,

Sergey Kornilov admin 12/14/2005

You can not use a column values instead of keywords in INTERVAL clause.
You should either use CASE function or re-design your database.

D
defcon2000 author 12/14/2005

Thanks. I will use case.