Unix Technical Forum

conditionally set in update query

This is a discussion on conditionally set in update query within the MySQL forums, part of the Database Server Software category; --> Hallo, i want to update a datetime field conditionally. something like: update actions set finalDate = if (finalDate <> ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 11:11 AM
Sjef
 
Posts: n/a
Default conditionally set in update query

Hallo,
i want to update a datetime field conditionally. something like:

update actions set finalDate = if (finalDate <> '0000-00-00
00:00:00',now(),'0000-00-00 00:00:00') where actionsId = '20';

It didn't do what I want. Is there another way to conditionally do this or
should I use an extra query to see what the value og finalDate is?

Thanxs!!


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 11:11 AM
Sjef
 
Posts: n/a
Default Re: conditionally set in update query

Tonight it came to me that it should be possible to do it like this:

update actions set finalDate = now() where actionsId = '20' AND finalDate =
'0000-00-00 00:00:00')

Sorry


"Sjef" <manuals-scripts@planet.nl> schreef in bericht
news:468e4a7c$0$25492$ba620dc5@text.nova.planet.nl ...
> Hallo,
> i want to update a datetime field conditionally. something like:
>
> update actions set finalDate = if (finalDate <> '0000-00-00
> 00:00:00',now(),'0000-00-00 00:00:00') where actionsId = '20';
>
> It didn't do what I want. Is there another way to conditionally do this or
> should I use an extra query to see what the value og finalDate is?
>
> Thanxs!!
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:16 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com