Web lists-archives.com

Re: update and control flow




​You can use your login inline with nested IF expressions:

insert into foo(id,comment)
     values(17, IF(WORD like 'a%','a',IF(word like 'b%','b',null)));​



On Tue, Dec 9, 2014 at 9:50 AM, wagnerbianchi.com <me@xxxxxxxxxxxxxxxxx>
wrote:

> You can do that, but, perhaps the only chance to have it updating a row
> based on a condition is developing a Stored Procedure or even having a
> BEFORE Trigger associated with the main table. Those ways, you can test the
> sent value and decide on what UPDATE you will execute afterwards. Consider
> that this is just an opinion since I'm not part of the problem and cannot
> analyse all the requirements.
>
> WB
>
> 2014-12-09 12:25 GMT-02:00 Martin Mueller <martinmueller@xxxxxxxxxxxxxxxx
> >:
>
> > 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
> > something like
> >
> > UPDATE X
> >
> > if WORD like 'a%' SET COMMENT = 'a'
> > elseif WORD like 'b%' SET COMMENT = 'b'
> > END IF
> >
> >
> > But this gives me an error message. What am I doing wrong?
> >
> > MM
> >
> > Martin Mueller
> >
> > Professor emeritus of English and Classics
> > Northwestern University
> >
> >
> >
> >
> >
> > --
> > MySQL General Mailing List
> > For list archives: http://lists.mysql.com/mysql
> > To unsubscribe:    http://lists.mysql.com/mysql
> >
> >
>



-- 
 - michael dykman
 - mdykman@xxxxxxxxx

 May the Source be with you.