mysql5.7 and mysql 5.6 group by the difference

#表的结构 test3
CREATE TABLE IF NOT EXISTS test3 (
id int(11) NOT NULL auto_increment,
bid int(11) NOT NULL,
cid int(11) NOT NULL,
dtime datetime NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

# Transfer data stored in the table test3

INSERT INTO test3 (idbidciddtime) VALUES
(1, 1, 3, ‘2014-03-18 16:00:00’),
(2, 1, 10, ‘2014-03-18 17:00:00’),
(3, 2, 5, ‘2014-03-18 18:00:00’),
(4, 2, 6, ‘2014-03-18 19:00:00’),
(5, 1, 7, ‘2014-03-18 20:00:00’);

Second, by subqueries

1, sql statement

select from(select from test3 ORDER BY dtime DESC) as temp GROUP BY bid ORDER BY dtime DESC;

So the question is

Some computer bid = 1 is set 5.7mysql 16:00, 5.67mysql is 20 points, that is opposite to the

By explain view the execution plan, you can see there is no limit of time, one less DERIVED internal operations is estimated to be optimized, that the ORDER BY syntax in which there is negligible LIMIT restrictions involving the result of the sort, do not ignore the ORDER BY, can achieve the desired
test it,
the SELECT  from (the SELECT  from Test3 the ORDER BY DESC limit DTIME 999999999) AS the TEMP Bid the ORDER BY DTIME the GROUP BY
can, however inelegant
official website information
https://dev.mysql.com/doc/refman/5.7 /en/group-by-handling.html
description official website
may also be so
SELECT  from (SELECT the DISTINCT  from the ORDER BY Test3 DTIME DESC) AS TEMP Bid the GROUP BY the ORDER BY ID desc

Guess you like

Origin www.cnblogs.com/phpcurd/p/11699378.html