MySQL Forums
Forum List  »  InnoDB

Re: COUNT(*) on innodb
Posted by: Jay Pipes
Date: November 24, 2005 01:32PM

You'd think, but because of the way MySQL does date arithmetic, it views the difference as 0 because they are in the same day. Instead, use TIMEDIFF():

mysql> SELECT @1:=NOW();
+---------------------+
| @1:=NOW() |
+---------------------+
| 2005-11-24 14:18:50 |
+---------------------+
1 row in set (0.00 sec)

mysql> SELECT @2:=NOW();
+---------------------+
| @2:=NOW() |
+---------------------+
| 2005-11-24 14:18:53 |
+---------------------+
1 row in set (0.00 sec)

mysql> SELECT TIMEDIFF(@2,@1);
+-----------------+
| TIMEDIFF(@2,@1) |
+-----------------+
| 00:00:03 |
+-----------------+
1 row in set (0.00 sec)

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Views
Written By
Posted
12458
November 24, 2005 09:15AM
4775
November 24, 2005 09:46AM
4488
November 24, 2005 11:53AM
4180
November 24, 2005 12:16PM
4134
November 24, 2005 12:39PM
3775
November 24, 2005 12:55PM
4277
November 24, 2005 01:03PM
3280
November 24, 2005 01:11PM
Re: COUNT(*) on innodb
3231
November 24, 2005 01:32PM
2974
November 24, 2005 02:07PM
3516
November 24, 2005 08:00PM
2981
November 24, 2005 08:38PM
2829
November 25, 2005 05:15PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.