![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, Can someone smart please let me know what's wrong with this statement? UPDATE table CASE WHEN type='longvalue' THEN SET longvalue='Results' ELSE SET value='Results' END WHERE id=10 Thanks, cron |
#3
| |||
| |||
|
|
On 10/30/2010 6:41 PM, cronoklee wrote: Hi, Can someone smart please let me know what's wrong with this statement? UPDATE table CASE WHEN type='longvalue' THEN SET longvalue='Results' ELSE SET value='Results' END WHERE id=10 Thanks, cron What's your table definition and what error message do you get? -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstuck... (AT) attglobal (DOT) net ================== |
#4
| |||
| |||
|
|
Hi, Can someone smart please let me know what's wrong with this statement? UPDATE table CASE WHEN type='longvalue' THEN SET longvalue='Results' ELSE SET value='Results' END WHERE id=10 |
#5
| |||
| |||
|
|
On 31 Oct, 01:42, Jerry Stuckle<jstuck... (AT) attglobal (DOT) net> wrote: On 10/30/2010 6:41 PM, cronoklee wrote: Hi, Can someone smart please let me know what's wrong with this statement? UPDATE table CASE WHEN type='longvalue' THEN SET longvalue='Results' ELSE SET value='Results' END WHERE id=10 Thanks, cron What's your table definition and what error message do you get? HI Jerry, Error is [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASE WHEN type='longvalue' THEN SET longvalue='Results' ELSE SET value='Result' at line 2 Table is myISAM `id` mediumint(9) NOT NULL auto_increment `type` varchar(20) NOT NULL `value` varchar(255) default NULL `longvalue` blob Thanks, cron |
#6
| |||
| |||
|
|
On 2010-10-31 00:41, cronoklee wrote: Hi, Can someone smart please let me know what's wrong with this statement? UPDATE table CASE WHEN type='longvalue' THEN SET longvalue='Results' ELSE SET value='Results' END WHERE id=10 You cannot use a case statement the way you are trying to. Basically you will have to update a column via a case statement, you cannot choose column in the case statement: update table * * set longvalue = case when type = 'longvalue' * * * * * * * * * * * * * * * then 'Results' * * * * * * * * * * * * * * * else longvalue * * * * * * * * * * end, * * * * value = case ... where id = 10; I'd say that the scenario you are describing is rather unusual, is there something wrong with the design of your database? /Lennart |
![]() |
| Thread Tools | |
| Display Modes | |
| |