Re: conditional updating

2012-02-11 Thread william drescher

On 2/9/2012 8:58 AM, Reindl Harald wrote:



Am 09.02.2012 14:55, schrieb william drescher:

On 2/9/2012 8:22 AM, Johnny Withers wrote:

Update table set mydate=now() where mydate='-00-00'; should do it.

  can't do that because the record is selected by other criteria.


so explain the criteria, show us the query

usually you do exatcly the same WHERE as for the select and add
and mydate='-00-00'



The query was to find a record by a unique ID, then update last 
access to now, and then update first access date to curdate() if 
it is -00-00.


So, I obviously can not select the record based on first access 
as I need to update it regardless of the value of first access.


IF() works like a charm.

bill


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



conditional updating

2012-02-09 Thread william drescher
I want to update a date field in a record. if the date in the 
field is -00-00 I want to change it to the current date.  I 
would appreciate suggestions or links on how to do this.


Yup, tried reading the manual, but need a bit of help.
I will be updating another field at the same time.

bill


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: conditional updating

2012-02-09 Thread Michael Dykman
untested:

update  set mydate = IF(mydate =  '-00-00', now(), mydate)

 - michael dykman

On Thu, Feb 9, 2012 at 8:14 AM, william drescher
will...@techservsys.com wrote:
 I want to update a date field in a record. if the date in the field is
 -00-00 I want to change it to the current date.  I would appreciate
 suggestions or links on how to do this.

 Yup, tried reading the manual, but need a bit of help.
 I will be updating another field at the same time.

 bill


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:    http://lists.mysql.com/mysql




-- 
 - michael dykman
 - mdyk...@gmail.com

 May the Source be with you.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: conditional updating

2012-02-09 Thread Johnny Withers
Update table set mydate=now() where mydate='-00-00'; should do it.

Sent from my iPad

On Feb 9, 2012, at 7:15 AM, william drescher will...@techservsys.com wrote:

 I want to update a date field in a record. if the date in the field is 
 -00-00 I want to change it to the current date.  I would appreciate 
 suggestions or links on how to do this.

 Yup, tried reading the manual, but need a bit of help.
 I will be updating another field at the same time.

 bill


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: conditional updating

2012-02-09 Thread william drescher

On 2/9/2012 8:22 AM, Johnny Withers wrote:

Update table set mydate=now() where mydate='-00-00'; should do it.

 can't do that because the record is selected by other criteria.
Thanks

bill



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: conditional updating

2012-02-09 Thread Reindl Harald


Am 09.02.2012 14:55, schrieb william drescher:
 On 2/9/2012 8:22 AM, Johnny Withers wrote:
 Update table set mydate=now() where mydate='-00-00'; should do it.
  can't do that because the record is selected by other criteria.

so explain the criteria, show us the query

usually you do exatcly the same WHERE as for the select and add
and mydate='-00-00'



signature.asc
Description: OpenPGP digital signature


Re: conditional updating

2012-02-09 Thread william drescher

On 2/9/2012 8:18 AM, Michael Dykman wrote:

untested:

update  set mydate = IF(mydate =  '-00-00', now(), mydate)

  - michael dykman



Thank you very much !

bill

On Thu, Feb 9, 2012 at 8:14 AM, william drescher
will...@techservsys.com  wrote:

I want to update a date field in a record. if the date in the field is
-00-00 I want to change it to the current date.  I would appreciate
suggestions or links on how to do this.

Yup, tried reading the manual, but need a bit of help.
I will be updating another field at the same time.

bill


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql









--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: conditional updating

2012-02-09 Thread Johnny Withers
So, add your other criteria to the where clause, you failed to say
there were other conditions in your first email.

Sent from my iPad

On Feb 9, 2012, at 7:56 AM, william drescher will...@techservsys.com wrote:

 On 2/9/2012 8:22 AM, Johnny Withers wrote:
 Update table set mydate=now() where mydate='-00-00'; should do it.
 can't do that because the record is selected by other criteria.
 Thanks

 bill



 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: conditional updating

2012-02-09 Thread Michael Dykman
He did mention that there was another field he was updating, which
implies that the state of the date field was not the only condition.

 - michael

On Thu, Feb 9, 2012 at 9:22 AM, Johnny Withers joh...@pixelated.net wrote:
 So, add your other criteria to the where clause, you failed to say
 there were other conditions in your first email.

 Sent from my iPad

 On Feb 9, 2012, at 7:56 AM, william drescher will...@techservsys.com wrote:

 On 2/9/2012 8:22 AM, Johnny Withers wrote:
 Update table set mydate=now() where mydate='-00-00'; should do it.
 can't do that because the record is selected by other criteria.
 Thanks

 bill



 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:    http://lists.mysql.com/mysql


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:    http://lists.mysql.com/mysql




-- 
 - michael dykman
 - mdyk...@gmail.com

 May the Source be with you.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: conditional updating

2012-02-09 Thread Johnny Withers
It implied to me there were two fields to update based on the date
being a given value. Read it how you like.

Sent from my iPad

On Feb 9, 2012, at 9:34 AM, Michael Dykman mdyk...@gmail.com wrote:

 He did mention that there was another field he was updating, which
 implies that the state of the date field was not the only condition.

 - michael

 On Thu, Feb 9, 2012 at 9:22 AM, Johnny Withers joh...@pixelated.net wrote:
 So, add your other criteria to the where clause, you failed to say
 there were other conditions in your first email.

 Sent from my iPad

 On Feb 9, 2012, at 7:56 AM, william drescher will...@techservsys.com wrote:

 On 2/9/2012 8:22 AM, Johnny Withers wrote:
 Update table set mydate=now() where mydate='-00-00'; should do it.
 can't do that because the record is selected by other criteria.
 Thanks

 bill



 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql




 --
  - michael dykman
  - mdyk...@gmail.com

  May the Source be with you.

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql