Comments on: MySQL: Conditional Update http://www.terminally-incoherent.com/blog/2009/10/05/mysql-conditional-update/ I will not fix your computer. Tue, 04 Aug 2020 22:34:33 +0000 hourly 1 https://wordpress.org/?v=4.7.26 By: Tino http://www.terminally-incoherent.com/blog/2009/10/05/mysql-conditional-update/#comment-13306 Wed, 07 Oct 2009 02:22:24 +0000 http://www.terminally-incoherent.com/blog/?p=3893#comment-13306

Luke Maciak wrote:

LOL! Good point. I’m making this more complex than it needs to be, aren’t I?

:D. But, as you say, it is a good hint that the IF operator (or CASE, which I thought were more portable?) can be useful also as part of UPDATEs, and not only SELECTs.

Reply  |  Quote
]]>
By: Luke Maciak http://www.terminally-incoherent.com/blog/2009/10/05/mysql-conditional-update/#comment-13298 Tue, 06 Oct 2009 04:43:21 +0000 http://www.terminally-incoherent.com/blog/?p=3893#comment-13298

@ Tino:

LOL! Good point. I’m making this more complex than it needs to be, aren’t I?

Then again, the traditional format won’t work in the second high-low example so this format is still useful for creating compact MySQL queries. :)

Reply  |  Quote
]]>
By: Tino http://www.terminally-incoherent.com/blog/2009/10/05/mysql-conditional-update/#comment-13297 Tue, 06 Oct 2009 03:22:38 +0000 http://www.terminally-incoherent.com/blog/?p=3893#comment-13297

Or, why not just the more portable:
UPDATE mytable SET foo=’bar’ WHERE id=’69’ and foo IS NULL;

Reply  |  Quote
]]>
By: Ryan http://www.terminally-incoherent.com/blog/2009/10/05/mysql-conditional-update/#comment-13295 Mon, 05 Oct 2009 18:38:30 +0000 http://www.terminally-incoherent.com/blog/?p=3893#comment-13295

For what it’s worth, I like these posts. Keep ’em coming.

Reply  |  Quote
]]>