If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Creating Event to auto_update datetime field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-16-07, 14:57
johnnysc johnnysc is offline
Registered User
 
Join Date: Nov 2004
Posts: 28
Creating Event to auto_update datetime field

I have an 'hours' table for restaurants with an 'open_time' and 'close_time' field in them. I need to create an event that at midnight each night both of those fields are updated by adding one day to them. (i.e. open_time is 2007-02-15 08:00:00 which then would be 2007-02-16 08:00:00). Because the table is in use i created a 'temp' table with the exact same fields and rows as the hours table to temporarily update these colums. I have the query that will do this but it is requring me to have a where statement state what row to update.

the query i have is:
Code:
UPDATE temp SET close_time = (  SELECT date_add( close_time,  INTERVAL 1  DAY  )  FROM hours where hours_id=1)  WHERE hours_id = 1
how do i make this go through and update the temp table for each row?

Thanks,
John
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On