Re: update and control flow
- Date: Tue, 09 Dec 2014 13:00:00 -0500
- From: hsv@xxxxxxxx
- Subject: Re: update and control flow
>>>> 2014/12/09 14:25 +0000, Martin Mueller >>>>
I'm trying to get my feet wet with 'if' and 'when' uses in mysql. it would be very useful for update operations, but I can't get it right.
If I read the documentation correctly, it should be possible to say
if WORD like 'a%' SET COMMENT = 'a'
elseif WORD like 'b%' SET COMMENT = 'b'
But this gives me an error message. What am I doing wrong?
You have seen Sean Green s good changes. You need to know where what form is allowed.
There is an IF statement which is allowed within stored procedures and triggers, but not in queries or open code.
There is also a function of the same name that takes three arguments: condition, TRUE choice, not-TRUE choice.
There are also CASE statement and CASE operator, whereto WHEN belongs. The statement and operator look not quite alike: the statement ends with END CASE, the operator with END, and the ELSE NULL allowed for the operator is not allowed for the statement.
CASE statement and operator, and IF statement, take THEN between the condition and the "conclusion".
(If you want to try the statement forms, write a trigger or a stored procedure.)
The statement forms do not apply to your example. The function and operator forms that Sean Green used do, and also the conditions WHERE and HAVING, each with its own use.
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql