473,480 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Same SQL, Same table structure, different results?

I stumbled across this while trying to update a table with a timestamp type column. At the time, I didn't know that the timstamp column would update itself when a row was changed. A kind gentleman in another group pointed that out to me.

I added a column to a table and wanted to update the rows to populate the new column. When doing something like this I usually will create a temporary table and perform a dry run, just to make sure I am producing the results I want. In this case, it did exactly what I wanted to the temporary table, but gave different results to the real table.

It appears that the timestamp field does not automatically update in a temporary table, but does in the real table. Have I found a MySQL bug, or does it behave this way by design?

JM
----------------------------------------------------------------
(MySQL server version 3.23.55-Max)

mysql> create temporary table jim select * from MonthEnd;
Query OK, 39 rows affected (0.00 sec)
Records: 39 Duplicates: 0 Warnings: 0

mysql> describe jim;
+-----------+--------------+------+-----+------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+------------+-------+
| YYMM | timestamp(4) | YES | | NULL | |
| BeginDate | date | | | 0000-00-00 | |
| EndDate | date | | | 0000-00-00 | |
| Weeks | decimal(1,0) | YES | | NULL | |
+-----------+--------------+------+-----+------------+-------+
4 rows in set (0.00 sec)


mysql> select * from jim;
+------+------------+------------+-------+
| YYMM | BeginDate | EndDate | Weeks |
+------+------------+------------+-------+
| 0110 | 2001-09-30 | 2001-10-27 | NULL |
| 0111 | 2001-10-28 | 2001-12-01 | NULL |
| 0112 | 2001-12-02 | 2001-12-28 | NULL |
| 0201 | 2001-12-29 | 2002-01-26 | NULL |
| 0202 | 2002-01-27 | 2002-02-23 | NULL |
| 0203 | 2002-02-24 | 2002-03-30 | NULL |
| 0204 | 2002-03-31 | 2002-04-27 | NULL |
| 0205 | 2002-04-28 | 2002-05-25 | NULL |
| 0206 | 2002-05-26 | 2002-06-29 | NULL |
| 0207 | 2002-06-30 | 2002-08-03 | NULL |
| 0208 | 2002-08-04 | 2002-08-31 | NULL |
| 0209 | 2002-09-01 | 2002-10-05 | NULL |
| 0210 | 2002-10-06 | 2002-11-02 | NULL |
| 0211 | 2002-11-03 | 2002-11-30 | NULL |
| 0212 | 2002-12-01 | 2003-01-03 | NULL |
| 0301 | 2003-01-04 | 2003-02-01 | NULL |
| 0302 | 2003-02-02 | 2003-03-01 | NULL |
| 0303 | 2003-03-02 | 2003-04-05 | NULL |
| 0304 | 2003-04-06 | 2003-05-03 | NULL |
| 0305 | 2003-05-04 | 2003-05-31 | NULL |
| 0306 | 2003-06-01 | 2003-07-05 | NULL |
| 0307 | 2003-07-06 | 2003-08-02 | NULL |
| 0308 | 2003-08-03 | 2003-08-30 | NULL |
| 0309 | 2003-08-31 | 2003-10-04 | NULL |
| 0310 | 2003-10-05 | 2003-11-01 | NULL |
| 0311 | 2003-11-02 | 2003-11-29 | NULL |
| 0312 | 2003-11-30 | 2004-01-02 | NULL |
| 0401 | 2004-01-03 | 2004-01-31 | 4 |
| 0402 | 2004-02-01 | 2004-02-28 | 4 |
| 0403 | 2004-02-29 | 2004-04-03 | 5 |
| 0404 | 2004-04-04 | 2004-05-01 | 4 |
| 0405 | 2004-05-02 | 2004-05-29 | 4 |
| 0406 | 2004-05-30 | 2004-07-03 | 5 |
| 0407 | 2004-07-04 | 2004-07-31 | 4 |
| 0408 | 2004-08-01 | 2004-08-28 | 4 |
| 0409 | 2004-08-29 | 2004-10-02 | 5 |
| 0410 | 2004-10-03 | 2004-10-30 | 4 |
| 0411 | 2004-10-31 | 2004-11-27 | 4 |
| 0412 | 2004-11-28 | 2004-12-31 | 5 |
+------+------------+------------+-------+
39 rows in set (0.01 sec)

mysql> update jim set Weeks = round((TO_DAYS(EndDate)-TO_DAYS(BeginDate))/7);
Query OK, 27 rows affected (0.00 sec)
Rows matched: 39 Changed: 27 Warnings: 0

mysql> select * from jim;
+------+------------+------------+-------+
| YYMM | BeginDate | EndDate | Weeks |
+------+------------+------------+-------+
| 0110 | 2001-09-30 | 2001-10-27 | 4 |
| 0111 | 2001-10-28 | 2001-12-01 | 5 |
| 0112 | 2001-12-02 | 2001-12-28 | 4 |
| 0201 | 2001-12-29 | 2002-01-26 | 4 |
| 0202 | 2002-01-27 | 2002-02-23 | 4 |
| 0203 | 2002-02-24 | 2002-03-30 | 5 |
| 0204 | 2002-03-31 | 2002-04-27 | 4 |
| 0205 | 2002-04-28 | 2002-05-25 | 4 |
| 0206 | 2002-05-26 | 2002-06-29 | 5 |
| 0207 | 2002-06-30 | 2002-08-03 | 5 |
| 0208 | 2002-08-04 | 2002-08-31 | 4 |
| 0209 | 2002-09-01 | 2002-10-05 | 5 |
| 0210 | 2002-10-06 | 2002-11-02 | 4 |
| 0211 | 2002-11-03 | 2002-11-30 | 4 |
| 0212 | 2002-12-01 | 2003-01-03 | 5 |
| 0301 | 2003-01-04 | 2003-02-01 | 4 |
| 0302 | 2003-02-02 | 2003-03-01 | 4 |
| 0303 | 2003-03-02 | 2003-04-05 | 5 |
| 0304 | 2003-04-06 | 2003-05-03 | 4 |
| 0305 | 2003-05-04 | 2003-05-31 | 4 |
| 0306 | 2003-06-01 | 2003-07-05 | 5 |
| 0307 | 2003-07-06 | 2003-08-02 | 4 |
| 0308 | 2003-08-03 | 2003-08-30 | 4 |
| 0309 | 2003-08-31 | 2003-10-04 | 5 |
| 0310 | 2003-10-05 | 2003-11-01 | 4 |
| 0311 | 2003-11-02 | 2003-11-29 | 4 |
| 0312 | 2003-11-30 | 2004-01-02 | 5 |
| 0401 | 2004-01-03 | 2004-01-31 | 4 |
| 0402 | 2004-02-01 | 2004-02-28 | 4 |
| 0403 | 2004-02-29 | 2004-04-03 | 5 |
| 0404 | 2004-04-04 | 2004-05-01 | 4 |
| 0405 | 2004-05-02 | 2004-05-29 | 4 |
| 0406 | 2004-05-30 | 2004-07-03 | 5 |
| 0407 | 2004-07-04 | 2004-07-31 | 4 |
| 0408 | 2004-08-01 | 2004-08-28 | 4 |
| 0409 | 2004-08-29 | 2004-10-02 | 5 |
| 0410 | 2004-10-03 | 2004-10-30 | 4 |
| 0411 | 2004-10-31 | 2004-11-27 | 4 |
| 0412 | 2004-11-28 | 2004-12-31 | 5 |
+------+------------+------------+-------+
39 rows in set (0.00 sec) (* Notice the YYMM column didn't automatically update *)

mysql> update MonthEnd set Weeks = round((TO_DAYS(EndDate)-TO_DAYS(BeginDate))/7);
Query OK, 27 rows affected (0.00 sec)
Rows matched: 39 Changed: 27 Warnings: 0

mysql> select * from MonthEnd;
+------+------------+------------+-------+
| YYMM | BeginDate | EndDate | Weeks |
+------+------------+------------+-------+
| 0310 | 2003-11-02 | 2003-11-29 | 4 |
| 0310 | 2003-10-05 | 2003-11-01 | 4 |
| 0310 | 2003-08-31 | 2003-10-04 | 5 |
| 0310 | 2003-08-03 | 2003-08-30 | 4 |
| 0310 | 2003-07-06 | 2003-08-02 | 4 |
| 0310 | 2003-06-01 | 2003-07-05 | 5 |
| 0310 | 2003-05-04 | 2003-05-31 | 4 |
| 0310 | 2003-04-06 | 2003-05-03 | 4 |
| 0310 | 2003-03-02 | 2003-04-05 | 5 |
| 0310 | 2003-02-02 | 2003-03-01 | 4 |
| 0310 | 2003-01-04 | 2003-02-01 | 4 |
| 0310 | 2002-12-01 | 2003-01-03 | 5 |
| 0310 | 2002-11-03 | 2002-11-30 | 4 |
| 0310 | 2002-10-06 | 2002-11-02 | 4 |
| 0310 | 2002-09-01 | 2002-10-05 | 5 |
| 0310 | 2002-08-04 | 2002-08-31 | 4 |
| 0310 | 2002-06-30 | 2002-08-03 | 5 |
| 0310 | 2002-05-26 | 2002-06-29 | 5 |
| 0310 | 2002-04-28 | 2002-05-25 | 4 |
| 0310 | 2002-03-31 | 2002-04-27 | 4 |
| 0310 | 2002-02-24 | 2002-03-30 | 5 |
| 0310 | 2002-01-27 | 2002-02-23 | 4 |
| 0310 | 2001-12-29 | 2002-01-26 | 4 |
| 0310 | 2001-12-02 | 2001-12-28 | 4 |
| 0310 | 2001-10-28 | 2001-12-01 | 5 |
| 0310 | 2001-09-30 | 2001-10-27 | 4 |
| 0310 | 2003-11-30 | 2004-01-02 | 5 |
| 0401 | 2004-01-03 | 2004-01-31 | 4 |
| 0402 | 2004-02-01 | 2004-02-28 | 4 |
| 0403 | 2004-02-29 | 2004-04-03 | 5 |
| 0404 | 2004-04-04 | 2004-05-01 | 4 |
| 0405 | 2004-05-02 | 2004-05-29 | 4 |
| 0406 | 2004-05-30 | 2004-07-03 | 5 |
| 0407 | 2004-07-04 | 2004-07-31 | 4 |
| 0408 | 2004-08-01 | 2004-08-28 | 4 |
| 0409 | 2004-08-29 | 2004-10-02 | 5 |
| 0410 | 2004-10-03 | 2004-10-30 | 4 |
| 0411 | 2004-10-31 | 2004-11-27 | 4 |
| 0412 | 2004-11-28 | 2004-12-31 | 5 |
+------+------------+------------+-------+
39 rows in set (0.00 sec)
mysql>



Jul 19 '05 #1
2 1633
UPDATE: I have verified that this is a bug, and submitted a bug report to bugs.mysql.com.
"Jim Moseby" <no****@dontspam.me> wrote in message news:t9********************@giganews.com...
I stumbled across this while trying to update a table with a timestamp type column. At the time, I didn't know that the timstamp column would update itself when a row was changed. A kind gentleman in another group pointed that out to me.

I added a column to a table and wanted to update the rows to populate the new column. When doing something like this I usually will create a temporary table and perform a dry run, just to make sure I am producing the results I want. In this case, it did exactly what I wanted to the temporary table, but gave different results to the real table.

It appears that the timestamp field does not automatically update in a temporary table, but does in the real table. Have I found a MySQL bug, or does it behave this way by design?

JM
----------------------------------------------------------------
(MySQL server version 3.23.55-Max)

mysql> create temporary table jim select * from MonthEnd;
Query OK, 39 rows affected (0.00 sec)
Records: 39 Duplicates: 0 Warnings: 0

mysql> describe jim;
+-----------+--------------+------+-----+------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+------------+-------+
| YYMM | timestamp(4) | YES | | NULL | |
| BeginDate | date | | | 0000-00-00 | |
| EndDate | date | | | 0000-00-00 | |
| Weeks | decimal(1,0) | YES | | NULL | |
+-----------+--------------+------+-----+------------+-------+
4 rows in set (0.00 sec)


mysql> select * from jim;
+------+------------+------------+-------+
| YYMM | BeginDate | EndDate | Weeks |
+------+------------+------------+-------+
| 0110 | 2001-09-30 | 2001-10-27 | NULL |
| 0111 | 2001-10-28 | 2001-12-01 | NULL |
| 0112 | 2001-12-02 | 2001-12-28 | NULL |
| 0201 | 2001-12-29 | 2002-01-26 | NULL |
| 0202 | 2002-01-27 | 2002-02-23 | NULL |
| 0203 | 2002-02-24 | 2002-03-30 | NULL |
| 0204 | 2002-03-31 | 2002-04-27 | NULL |
| 0205 | 2002-04-28 | 2002-05-25 | NULL |
| 0206 | 2002-05-26 | 2002-06-29 | NULL |
| 0207 | 2002-06-30 | 2002-08-03 | NULL |
| 0208 | 2002-08-04 | 2002-08-31 | NULL |
| 0209 | 2002-09-01 | 2002-10-05 | NULL |
| 0210 | 2002-10-06 | 2002-11-02 | NULL |
| 0211 | 2002-11-03 | 2002-11-30 | NULL |
| 0212 | 2002-12-01 | 2003-01-03 | NULL |
| 0301 | 2003-01-04 | 2003-02-01 | NULL |
| 0302 | 2003-02-02 | 2003-03-01 | NULL |
| 0303 | 2003-03-02 | 2003-04-05 | NULL |
| 0304 | 2003-04-06 | 2003-05-03 | NULL |
| 0305 | 2003-05-04 | 2003-05-31 | NULL |
| 0306 | 2003-06-01 | 2003-07-05 | NULL |
| 0307 | 2003-07-06 | 2003-08-02 | NULL |
| 0308 | 2003-08-03 | 2003-08-30 | NULL |
| 0309 | 2003-08-31 | 2003-10-04 | NULL |
| 0310 | 2003-10-05 | 2003-11-01 | NULL |
| 0311 | 2003-11-02 | 2003-11-29 | NULL |
| 0312 | 2003-11-30 | 2004-01-02 | NULL |
| 0401 | 2004-01-03 | 2004-01-31 | 4 |
| 0402 | 2004-02-01 | 2004-02-28 | 4 |
| 0403 | 2004-02-29 | 2004-04-03 | 5 |
| 0404 | 2004-04-04 | 2004-05-01 | 4 |
| 0405 | 2004-05-02 | 2004-05-29 | 4 |
| 0406 | 2004-05-30 | 2004-07-03 | 5 |
| 0407 | 2004-07-04 | 2004-07-31 | 4 |
| 0408 | 2004-08-01 | 2004-08-28 | 4 |
| 0409 | 2004-08-29 | 2004-10-02 | 5 |
| 0410 | 2004-10-03 | 2004-10-30 | 4 |
| 0411 | 2004-10-31 | 2004-11-27 | 4 |
| 0412 | 2004-11-28 | 2004-12-31 | 5 |
+------+------------+------------+-------+
39 rows in set (0.01 sec)

mysql> update jim set Weeks = round((TO_DAYS(EndDate)-TO_DAYS(BeginDate))/7);
Query OK, 27 rows affected (0.00 sec)
Rows matched: 39 Changed: 27 Warnings: 0

mysql> select * from jim;
+------+------------+------------+-------+
| YYMM | BeginDate | EndDate | Weeks |
+------+------------+------------+-------+
| 0110 | 2001-09-30 | 2001-10-27 | 4 |
| 0111 | 2001-10-28 | 2001-12-01 | 5 |
| 0112 | 2001-12-02 | 2001-12-28 | 4 |
| 0201 | 2001-12-29 | 2002-01-26 | 4 |
| 0202 | 2002-01-27 | 2002-02-23 | 4 |
| 0203 | 2002-02-24 | 2002-03-30 | 5 |
| 0204 | 2002-03-31 | 2002-04-27 | 4 |
| 0205 | 2002-04-28 | 2002-05-25 | 4 |
| 0206 | 2002-05-26 | 2002-06-29 | 5 |
| 0207 | 2002-06-30 | 2002-08-03 | 5 |
| 0208 | 2002-08-04 | 2002-08-31 | 4 |
| 0209 | 2002-09-01 | 2002-10-05 | 5 |
| 0210 | 2002-10-06 | 2002-11-02 | 4 |
| 0211 | 2002-11-03 | 2002-11-30 | 4 |
| 0212 | 2002-12-01 | 2003-01-03 | 5 |
| 0301 | 2003-01-04 | 2003-02-01 | 4 |
| 0302 | 2003-02-02 | 2003-03-01 | 4 |
| 0303 | 2003-03-02 | 2003-04-05 | 5 |
| 0304 | 2003-04-06 | 2003-05-03 | 4 |
| 0305 | 2003-05-04 | 2003-05-31 | 4 |
| 0306 | 2003-06-01 | 2003-07-05 | 5 |
| 0307 | 2003-07-06 | 2003-08-02 | 4 |
| 0308 | 2003-08-03 | 2003-08-30 | 4 |
| 0309 | 2003-08-31 | 2003-10-04 | 5 |
| 0310 | 2003-10-05 | 2003-11-01 | 4 |
| 0311 | 2003-11-02 | 2003-11-29 | 4 |
| 0312 | 2003-11-30 | 2004-01-02 | 5 |
| 0401 | 2004-01-03 | 2004-01-31 | 4 |
| 0402 | 2004-02-01 | 2004-02-28 | 4 |
| 0403 | 2004-02-29 | 2004-04-03 | 5 |
| 0404 | 2004-04-04 | 2004-05-01 | 4 |
| 0405 | 2004-05-02 | 2004-05-29 | 4 |
| 0406 | 2004-05-30 | 2004-07-03 | 5 |
| 0407 | 2004-07-04 | 2004-07-31 | 4 |
| 0408 | 2004-08-01 | 2004-08-28 | 4 |
| 0409 | 2004-08-29 | 2004-10-02 | 5 |
| 0410 | 2004-10-03 | 2004-10-30 | 4 |
| 0411 | 2004-10-31 | 2004-11-27 | 4 |
| 0412 | 2004-11-28 | 2004-12-31 | 5 |
+------+------------+------------+-------+
39 rows in set (0.00 sec) (* Notice the YYMM column didn't automatically update *)

mysql> update MonthEnd set Weeks = round((TO_DAYS(EndDate)-TO_DAYS(BeginDate))/7);
Query OK, 27 rows affected (0.00 sec)
Rows matched: 39 Changed: 27 Warnings: 0

mysql> select * from MonthEnd;
+------+------------+------------+-------+
| YYMM | BeginDate | EndDate | Weeks |
+------+------------+------------+-------+
| 0310 | 2003-11-02 | 2003-11-29 | 4 |
| 0310 | 2003-10-05 | 2003-11-01 | 4 |
| 0310 | 2003-08-31 | 2003-10-04 | 5 |
| 0310 | 2003-08-03 | 2003-08-30 | 4 |
| 0310 | 2003-07-06 | 2003-08-02 | 4 |
| 0310 | 2003-06-01 | 2003-07-05 | 5 |
| 0310 | 2003-05-04 | 2003-05-31 | 4 |
| 0310 | 2003-04-06 | 2003-05-03 | 4 |
| 0310 | 2003-03-02 | 2003-04-05 | 5 |
| 0310 | 2003-02-02 | 2003-03-01 | 4 |
| 0310 | 2003-01-04 | 2003-02-01 | 4 |
| 0310 | 2002-12-01 | 2003-01-03 | 5 |
| 0310 | 2002-11-03 | 2002-11-30 | 4 |
| 0310 | 2002-10-06 | 2002-11-02 | 4 |
| 0310 | 2002-09-01 | 2002-10-05 | 5 |
| 0310 | 2002-08-04 | 2002-08-31 | 4 |
| 0310 | 2002-06-30 | 2002-08-03 | 5 |
| 0310 | 2002-05-26 | 2002-06-29 | 5 |
| 0310 | 2002-04-28 | 2002-05-25 | 4 |
| 0310 | 2002-03-31 | 2002-04-27 | 4 |
| 0310 | 2002-02-24 | 2002-03-30 | 5 |
| 0310 | 2002-01-27 | 2002-02-23 | 4 |
| 0310 | 2001-12-29 | 2002-01-26 | 4 |
| 0310 | 2001-12-02 | 2001-12-28 | 4 |
| 0310 | 2001-10-28 | 2001-12-01 | 5 |
| 0310 | 2001-09-30 | 2001-10-27 | 4 |
| 0310 | 2003-11-30 | 2004-01-02 | 5 |
| 0401 | 2004-01-03 | 2004-01-31 | 4 |
| 0402 | 2004-02-01 | 2004-02-28 | 4 |
| 0403 | 2004-02-29 | 2004-04-03 | 5 |
| 0404 | 2004-04-04 | 2004-05-01 | 4 |
| 0405 | 2004-05-02 | 2004-05-29 | 4 |
| 0406 | 2004-05-30 | 2004-07-03 | 5 |
| 0407 | 2004-07-04 | 2004-07-31 | 4 |
| 0408 | 2004-08-01 | 2004-08-28 | 4 |
| 0409 | 2004-08-29 | 2004-10-02 | 5 |
| 0410 | 2004-10-03 | 2004-10-30 | 4 |
| 0411 | 2004-10-31 | 2004-11-27 | 4 |
| 0412 | 2004-11-28 | 2004-12-31 | 5 |
+------+------------+------------+-------+
39 rows in set (0.00 sec)
mysql>



Jul 19 '05 #2
UPDATE: I have verified that this is a bug, and submitted a bug report to bugs.mysql.com.
"Jim Moseby" <no****@dontspam.me> wrote in message news:t9********************@giganews.com...
I stumbled across this while trying to update a table with a timestamp type column. At the time, I didn't know that the timstamp column would update itself when a row was changed. A kind gentleman in another group pointed that out to me.

I added a column to a table and wanted to update the rows to populate the new column. When doing something like this I usually will create a temporary table and perform a dry run, just to make sure I am producing the results I want. In this case, it did exactly what I wanted to the temporary table, but gave different results to the real table.

It appears that the timestamp field does not automatically update in a temporary table, but does in the real table. Have I found a MySQL bug, or does it behave this way by design?

JM
----------------------------------------------------------------
(MySQL server version 3.23.55-Max)

mysql> create temporary table jim select * from MonthEnd;
Query OK, 39 rows affected (0.00 sec)
Records: 39 Duplicates: 0 Warnings: 0

mysql> describe jim;
+-----------+--------------+------+-----+------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+------------+-------+
| YYMM | timestamp(4) | YES | | NULL | |
| BeginDate | date | | | 0000-00-00 | |
| EndDate | date | | | 0000-00-00 | |
| Weeks | decimal(1,0) | YES | | NULL | |
+-----------+--------------+------+-----+------------+-------+
4 rows in set (0.00 sec)


mysql> select * from jim;
+------+------------+------------+-------+
| YYMM | BeginDate | EndDate | Weeks |
+------+------------+------------+-------+
| 0110 | 2001-09-30 | 2001-10-27 | NULL |
| 0111 | 2001-10-28 | 2001-12-01 | NULL |
| 0112 | 2001-12-02 | 2001-12-28 | NULL |
| 0201 | 2001-12-29 | 2002-01-26 | NULL |
| 0202 | 2002-01-27 | 2002-02-23 | NULL |
| 0203 | 2002-02-24 | 2002-03-30 | NULL |
| 0204 | 2002-03-31 | 2002-04-27 | NULL |
| 0205 | 2002-04-28 | 2002-05-25 | NULL |
| 0206 | 2002-05-26 | 2002-06-29 | NULL |
| 0207 | 2002-06-30 | 2002-08-03 | NULL |
| 0208 | 2002-08-04 | 2002-08-31 | NULL |
| 0209 | 2002-09-01 | 2002-10-05 | NULL |
| 0210 | 2002-10-06 | 2002-11-02 | NULL |
| 0211 | 2002-11-03 | 2002-11-30 | NULL |
| 0212 | 2002-12-01 | 2003-01-03 | NULL |
| 0301 | 2003-01-04 | 2003-02-01 | NULL |
| 0302 | 2003-02-02 | 2003-03-01 | NULL |
| 0303 | 2003-03-02 | 2003-04-05 | NULL |
| 0304 | 2003-04-06 | 2003-05-03 | NULL |
| 0305 | 2003-05-04 | 2003-05-31 | NULL |
| 0306 | 2003-06-01 | 2003-07-05 | NULL |
| 0307 | 2003-07-06 | 2003-08-02 | NULL |
| 0308 | 2003-08-03 | 2003-08-30 | NULL |
| 0309 | 2003-08-31 | 2003-10-04 | NULL |
| 0310 | 2003-10-05 | 2003-11-01 | NULL |
| 0311 | 2003-11-02 | 2003-11-29 | NULL |
| 0312 | 2003-11-30 | 2004-01-02 | NULL |
| 0401 | 2004-01-03 | 2004-01-31 | 4 |
| 0402 | 2004-02-01 | 2004-02-28 | 4 |
| 0403 | 2004-02-29 | 2004-04-03 | 5 |
| 0404 | 2004-04-04 | 2004-05-01 | 4 |
| 0405 | 2004-05-02 | 2004-05-29 | 4 |
| 0406 | 2004-05-30 | 2004-07-03 | 5 |
| 0407 | 2004-07-04 | 2004-07-31 | 4 |
| 0408 | 2004-08-01 | 2004-08-28 | 4 |
| 0409 | 2004-08-29 | 2004-10-02 | 5 |
| 0410 | 2004-10-03 | 2004-10-30 | 4 |
| 0411 | 2004-10-31 | 2004-11-27 | 4 |
| 0412 | 2004-11-28 | 2004-12-31 | 5 |
+------+------------+------------+-------+
39 rows in set (0.01 sec)

mysql> update jim set Weeks = round((TO_DAYS(EndDate)-TO_DAYS(BeginDate))/7);
Query OK, 27 rows affected (0.00 sec)
Rows matched: 39 Changed: 27 Warnings: 0

mysql> select * from jim;
+------+------------+------------+-------+
| YYMM | BeginDate | EndDate | Weeks |
+------+------------+------------+-------+
| 0110 | 2001-09-30 | 2001-10-27 | 4 |
| 0111 | 2001-10-28 | 2001-12-01 | 5 |
| 0112 | 2001-12-02 | 2001-12-28 | 4 |
| 0201 | 2001-12-29 | 2002-01-26 | 4 |
| 0202 | 2002-01-27 | 2002-02-23 | 4 |
| 0203 | 2002-02-24 | 2002-03-30 | 5 |
| 0204 | 2002-03-31 | 2002-04-27 | 4 |
| 0205 | 2002-04-28 | 2002-05-25 | 4 |
| 0206 | 2002-05-26 | 2002-06-29 | 5 |
| 0207 | 2002-06-30 | 2002-08-03 | 5 |
| 0208 | 2002-08-04 | 2002-08-31 | 4 |
| 0209 | 2002-09-01 | 2002-10-05 | 5 |
| 0210 | 2002-10-06 | 2002-11-02 | 4 |
| 0211 | 2002-11-03 | 2002-11-30 | 4 |
| 0212 | 2002-12-01 | 2003-01-03 | 5 |
| 0301 | 2003-01-04 | 2003-02-01 | 4 |
| 0302 | 2003-02-02 | 2003-03-01 | 4 |
| 0303 | 2003-03-02 | 2003-04-05 | 5 |
| 0304 | 2003-04-06 | 2003-05-03 | 4 |
| 0305 | 2003-05-04 | 2003-05-31 | 4 |
| 0306 | 2003-06-01 | 2003-07-05 | 5 |
| 0307 | 2003-07-06 | 2003-08-02 | 4 |
| 0308 | 2003-08-03 | 2003-08-30 | 4 |
| 0309 | 2003-08-31 | 2003-10-04 | 5 |
| 0310 | 2003-10-05 | 2003-11-01 | 4 |
| 0311 | 2003-11-02 | 2003-11-29 | 4 |
| 0312 | 2003-11-30 | 2004-01-02 | 5 |
| 0401 | 2004-01-03 | 2004-01-31 | 4 |
| 0402 | 2004-02-01 | 2004-02-28 | 4 |
| 0403 | 2004-02-29 | 2004-04-03 | 5 |
| 0404 | 2004-04-04 | 2004-05-01 | 4 |
| 0405 | 2004-05-02 | 2004-05-29 | 4 |
| 0406 | 2004-05-30 | 2004-07-03 | 5 |
| 0407 | 2004-07-04 | 2004-07-31 | 4 |
| 0408 | 2004-08-01 | 2004-08-28 | 4 |
| 0409 | 2004-08-29 | 2004-10-02 | 5 |
| 0410 | 2004-10-03 | 2004-10-30 | 4 |
| 0411 | 2004-10-31 | 2004-11-27 | 4 |
| 0412 | 2004-11-28 | 2004-12-31 | 5 |
+------+------------+------------+-------+
39 rows in set (0.00 sec) (* Notice the YYMM column didn't automatically update *)

mysql> update MonthEnd set Weeks = round((TO_DAYS(EndDate)-TO_DAYS(BeginDate))/7);
Query OK, 27 rows affected (0.00 sec)
Rows matched: 39 Changed: 27 Warnings: 0

mysql> select * from MonthEnd;
+------+------------+------------+-------+
| YYMM | BeginDate | EndDate | Weeks |
+------+------------+------------+-------+
| 0310 | 2003-11-02 | 2003-11-29 | 4 |
| 0310 | 2003-10-05 | 2003-11-01 | 4 |
| 0310 | 2003-08-31 | 2003-10-04 | 5 |
| 0310 | 2003-08-03 | 2003-08-30 | 4 |
| 0310 | 2003-07-06 | 2003-08-02 | 4 |
| 0310 | 2003-06-01 | 2003-07-05 | 5 |
| 0310 | 2003-05-04 | 2003-05-31 | 4 |
| 0310 | 2003-04-06 | 2003-05-03 | 4 |
| 0310 | 2003-03-02 | 2003-04-05 | 5 |
| 0310 | 2003-02-02 | 2003-03-01 | 4 |
| 0310 | 2003-01-04 | 2003-02-01 | 4 |
| 0310 | 2002-12-01 | 2003-01-03 | 5 |
| 0310 | 2002-11-03 | 2002-11-30 | 4 |
| 0310 | 2002-10-06 | 2002-11-02 | 4 |
| 0310 | 2002-09-01 | 2002-10-05 | 5 |
| 0310 | 2002-08-04 | 2002-08-31 | 4 |
| 0310 | 2002-06-30 | 2002-08-03 | 5 |
| 0310 | 2002-05-26 | 2002-06-29 | 5 |
| 0310 | 2002-04-28 | 2002-05-25 | 4 |
| 0310 | 2002-03-31 | 2002-04-27 | 4 |
| 0310 | 2002-02-24 | 2002-03-30 | 5 |
| 0310 | 2002-01-27 | 2002-02-23 | 4 |
| 0310 | 2001-12-29 | 2002-01-26 | 4 |
| 0310 | 2001-12-02 | 2001-12-28 | 4 |
| 0310 | 2001-10-28 | 2001-12-01 | 5 |
| 0310 | 2001-09-30 | 2001-10-27 | 4 |
| 0310 | 2003-11-30 | 2004-01-02 | 5 |
| 0401 | 2004-01-03 | 2004-01-31 | 4 |
| 0402 | 2004-02-01 | 2004-02-28 | 4 |
| 0403 | 2004-02-29 | 2004-04-03 | 5 |
| 0404 | 2004-04-04 | 2004-05-01 | 4 |
| 0405 | 2004-05-02 | 2004-05-29 | 4 |
| 0406 | 2004-05-30 | 2004-07-03 | 5 |
| 0407 | 2004-07-04 | 2004-07-31 | 4 |
| 0408 | 2004-08-01 | 2004-08-28 | 4 |
| 0409 | 2004-08-29 | 2004-10-02 | 5 |
| 0410 | 2004-10-03 | 2004-10-30 | 4 |
| 0411 | 2004-10-31 | 2004-11-27 | 4 |
| 0412 | 2004-11-28 | 2004-12-31 | 5 |
+------+------------+------------+-------+
39 rows in set (0.00 sec)
mysql>



Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1898
by: Dariusz | last post by:
I have written a database that counts the number of times a file has been accessed, so I can then later display the results on what is "hot" and what is not. At the moment all it does is count the...
0
7660
by: Priscilla Walther | last post by:
Hi All - I'm a newbie to the database area, but have inherited a MySQL database to manage along with my development duties. We have a very large MySQL database, and the designer of the...
0
1856
by: Jim Moseby | last post by:
I stumbled across this while trying to update a table with a timestamp type column. At the time, I didn't know that the timstamp column would update itself when a row was changed. A kind gentleman...
2
15612
by: zwylle | last post by:
Hi all, to avoid a nervous breakdown I finally decided to seek help :D I have a table defined with plain color background and in some cells I show pictures to frame my site. The problem I...
1
1739
by: RM | last post by:
I am using DataSet's .ReadXml() method to parse an XML file that has an inline schema and Im getting "different" results on various machines using the same myDataSet.ReadXml("myExample.xml"). ...
5
2059
by: Stewart Allen | last post by:
Hi all, I'm designing a club database and have encountered a problem when trying to extract the total amount of fees that a Student/Family is suppose to pay during their time of membership. I've...
3
3147
by: ChadDiesel | last post by:
Hello everyone. I need some advice on table structure for a new project I've been given. One of our customers sends us an Excel spreadsheet each week containing their order. Currently, someone...
82
12538
by: zardoz | last post by:
I've got this problem: unsigned long long lTemp; char cLargeNum="1324567890"; sscanf(clargeNum,"%llu",&lTemp); which under Win32 isn't working*. My program needs to compile under posix so...
2
1320
PEB
by: PEB | last post by:
When I use the statement: Set objDatasheet = Application.Screen.ActiveDatasheet there is no problem on the majority of machines, but on one or two of them Visual Basic generates this kind...
4
1474
by: fran7 | last post by:
Hi, I wonder if anyone can tell me how to write this query properly as this one doesnt work. where tbl.gallery='Abstract' and tbl.gallery='Abstract art' Need to query the same table for the...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7043
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6737
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6921
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5336
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4776
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.