![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello everybody, I'm relatively new in database management and programming, and I have a simple question: I need to update a Date Field in multiple records in this way: first record's Date field must have a certain date. Second record must have the previous date plus a week. Third record must have the date of second record plus a week, and so on. The question is: is there a way to do this automatically? |
#3
| |||
| |||
|
|
What does first, second etc. mean, i.e. by what criteria are you ordering the resultset? /Lennart |
#4
| |||
| |||
|
|
What does first, second etc. mean, i.e. by what criteria are you ordering the resultset? /Lennart i'm ordering the records by ID. i have a certain number of records. I would cange the date field of all these records at once. for example: I have 5 records, ordered by id (first record: ID=1, second record: ID=2, ecc); all these records have a Date field set: 2010-01-01 00:00:00. So, i would cange Date field in this way: record 1 (ID=1, Date 2010-10-05); record 2: (ID=2, Date 2010-10-12), record 3: (ID=3, Date= 2010-10-19), record 4: (ID=4, Date= 2010-10-26), etc... Is there a way to do this using some kind of sintax in MySQL, or I have to do a script in another language (PHP, ASP, etc)? |
#5
| |||
| |||
|
|
Something like: update t set d = '2010-10-05' + interval (id-1) week; /Lennart |

![]() |
| Thread Tools | |
| Display Modes | |
| |