Hey SQL gurus,

I am trying to use a CASE statement in a MySQL query to conditionally update 
a number of rows in a table.

However, if I try to use anything in the "THEN" clause other than a string, 
it fails with "Error in SQL syntax."

I am trying to set values in the table differently depending on a condition, 
like so (simplified):

UPDATE myTable
SET
CASE WHEN cond1
THEN col1 = col1 - 1, col2 = col2 - 1
WHEN cond2
THEN col1 = col1 - 2, col2 = col2 - 2
etc.
END

I also tried putting the SET after the THEN and it also fails.

Is there any way to make this happen all in one query, or am I going to have 
to go outside of SQL and do a CF loop?

-- Josh



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264939
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to