List:General Discussion« Previous MessageNext Message »
From:tony Date:August 10 1999 8:43am
Subject:Bug with SELECT DISTINCT on DATES
View as plain text  
>Description:

A select distinct using date_format and date_sub doesn't return distinct results.

>How-To-Repeat:

CREATE TABLE testsale (
  saleid mediumint(8) unsigned DEFAULT '0' NOT NULL auto_increment,
  when datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
  PRIMARY KEY (saleid)
);

INSERT INTO testsale VALUES (1,'1999-08-08 19:27:44');
INSERT INTO testsale VALUES (2,'1999-08-08 21:47:04');
INSERT INTO testsale VALUES (3,'1999-08-09 01:10:51');
INSERT INTO testsale VALUES (4,'1999-08-09 01:16:05');
INSERT INTO testsale VALUES (5,'1999-08-09 02:03:08');
INSERT INTO testsale VALUES (6,'1999-08-10 11:18:59');
INSERT INTO testsale VALUES (7,'1999-08-10 11:32:28');
INSERT INTO testsale VALUES (8,'1999-08-10 12:50:44');

select distinct date_format(when, "ymd") from testsale where when > DATE_SUB(now(),
INTERVAL 2 DAY) order by when;

+--------------------------+
| date_format(when, "ymd") |
+--------------------------+
| 990808                   |
| 990808                   |
| 990809                   |
| 990809                   |
| 990809                   |
| 990810                   |
| 990810                   |
| 990810                   |
+--------------------------+


Tony


>Submitter-Id:	<submitter ID>
>Originator:	Tony Bowden
>Organization:  TMtm
>MySQL support: email support 
>Synopsis:	select distinct using date_format and date_sub doesn't return distinct
> results
>Severity:	serious 
>Priority:	medium 
>Category:	mysql
>Class:		sw-bug 
>Release:	mysql-3.22.20a (TCX binary)
>Server: /usr/local/mysql/bin/mysqladmin  Ver 7.8 Distrib 3.22.20a, for pc-linux-gnu on
> i686
TCX Datakonsult AB, by Monty

Server version		3.22.20a
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/tmp/mysql.sock
Uptime:			22 hours 25 min 19 sec

Threads: 19  Questions: 7363473  Slow queries: 382  Opens: 182000  Flush tables: 1  Open
tables: 63
>Environment:
System: Linux pyxis 2.2.9 #2 SMP Wed Aug 4 22:31:29 BST 1999 i686 unknown
Architecture: i686

Some paths:  /usr/local/bin/perl /usr/bin/make /usr/bin/gcc /usr/bin/cc
GCC: Reading specs from /usr/lib/gcc-lib/i486-linux/2.7.2.3/specs
gcc version 2.7.2.3
Compilation info: CC='gcc'  CFLAGS='-O6 -mpentium -fomit-frame-pointer'  CXX='gcc' 
CXXFLAGS='-O6 -mpentium -fomit-frame-pointer -felide-constructors'  LDFLAGS='-static'
Configure command: ./configure  --prefix=/usr/local/mysql '--with-comment=TCX binary'
--enable-assembler --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static
--disable-shared
Perl: This is perl, version 5.004_04 built for i386-linux
Thread
Bug with SELECT DISTINCT on DATEStony10 Aug
  • Bug with SELECT DISTINCT on DATESsinisa10 Aug