Bug #88050 loss data with order by and limit0,1
Submitted: 11 Oct 2017 7:47 Modified: 17 Oct 2017 14:57
Reporter: Jack Sword Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.6.29-TDDL-5.1.28-1349132 OS:Linux
Assigned to: CPU Architecture:Any

[11 Oct 2017 7:47] Jack Sword
Description:
I have some datas on my db with a datetime typed column named createDate, and the data is like '2017-10-10 00:00:00';
when I search(select) this data by 'select expressName from core_express_cash_payment where merchantId = 117164 order by createDate desc' the results are like 魏明\n陈红梅\n陈明\n李振\n弘扬\n陈红梅;

so I think if I use DML like this, 'select expressName from core_express_cash_payment where merchantId = 117164 order by createDate desc limit 0,1' the result will be '魏明' but i got '陈红梅';

And , another point ,any DMLs i used with order by  and limit are all can not find '魏明',these DMLs includes : limit 0,1, limit 0,2, limit 0,3

I'm not sure if it because the 'order by' is not work well when it faces datas like '2017-10-11 00:00:00', but if so, please fix this; 

Thanks a lot

hope someone can see this and send me back on mail: dmk140416@163.com

How to repeat:
here are DDL and DMLS
DDL:
CREATE TABLE `core_express_cash_payment` (
  `id` varchar(32) NOT NULL COMMENT '主键ID',
  `merchantId` int(8) NOT NULL COMMENT '商户ID',
  `expressId` varchar(32) NOT NULL COMMENT '配送员ID',
  `expressName` varchar(20) NOT NULL COMMENT '配送员名称',
  `cash` float(8,2) DEFAULT '0.00' COMMENT '应缴纳的现金总额',
  `status` int(1) DEFAULT '0' COMMENT '状态(0:未确认、1:已确认)',
  `createDate` datetime DEFAULT NULL COMMENT '创建时间',
  `operateDate` datetime DEFAULT NULL COMMENT '确认时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;

INSERT INTO `core_express_cash_payment` VALUES ('3d7a784754374b7daa42932d97bf77a4', '117164', '861e6adbcb674747b09407cce57f7f90', '魏明', '9813.05', '1', '2017-10-10 00:00:00', '2017-10-11 15:34:02');
INSERT INTO `core_express_cash_payment` VALUES ('42e4dc8f8df44bd3826690a81a5e461b', '117164', '8a392abfbd884003b34ffb2df18b5c8f', '陈红梅', '15343.67', '1', '2017-10-10 00:00:00', '2017-10-11 15:34:58');
INSERT INTO `core_express_cash_payment` VALUES ('50e1d96d6d8341ce9b92524719b08667', '117164', '16b10fca2c3f44749177d586b5a1c300', '陈明', '10067.07', '1', '2017-10-10 00:00:00', '2017-10-11 15:34:04');
INSERT INTO `core_express_cash_payment` VALUES ('6b9314cfe6ad4b24ac90f2c4819de51f', '117164', 'b167e2ab39764ed1b496323fcc778190', '李振', '6323.41', '0', '2017-10-10 00:00:00', null);
INSERT INTO `core_express_cash_payment` VALUES ('c72e2ca03ee94f7c82feb6d65a16faef', '117164', '1e901530d3a5480d8ae801bddbf1863d', '弘扬', '16235.08', '1', '2017-10-10 00:00:00', '2017-10-11 15:34:08');
INSERT INTO `core_express_cash_payment` VALUES ('ef2ccff2a74d4632aad3a06250bf68de', '117164', '8a392abfbd884003b34ffb2df18b5c8f', '陈红梅', '1930.31', '1', '2017-10-11 15:26:29', '2017-10-11 15:34:37');

DML:
select expressName from core_express_cash_payment where merchantId = 117164 order by createDate desc

select expressName from core_express_cash_payment where merchantId = 117164 order by createDate desc limit 0,1
[11 Oct 2017 7:50] Jack Sword
all data without  keyword  limit

Attachment: no limit.png (image/png, text), 40.96 KiB.

[11 Oct 2017 7:51] Jack Sword
with keyword limit

Attachment: limit 0,1.png (image/png, text), 21.63 KiB.

[17 Oct 2017 14:57] MySQL Verification Team
Hi!

Thank you for your bug report. However, it is not a bug. Do note that column `createDate` has identical values for five of six rows. That means that when you choose LIMIT 1, MySQL is at liberty to present any of the five tuples.
f
This is fully in accordance with the latest ANSI SQL standard.