Details
Description
CREATE TABLE t (pk int PRIMARY KEY); |
INSERT INTO t (pk) VALUES (1),(2),(3); |
|
SELECT pk FROM t GROUP BY pk HAVING pk != 0 ORDER BY pk DESC LIMIT 1; |
SELECT (SELECT pk FROM t GROUP BY pk HAVING pk != 0 ORDER BY pk DESC LIMIT 1) s; |
|
# Cleanup
|
DROP TABLE t; |
10.3 7a98d232 |
SELECT pk FROM t GROUP BY pk HAVING pk != 0 ORDER BY pk DESC LIMIT 1; |
pk
|
3
|
SELECT (SELECT pk FROM t GROUP BY pk HAVING pk != 0 ORDER BY pk DESC LIMIT 1) s; |
s
|
1
|
3 is the expected result.
Reproducible with at least MyISAM, InnoDB, Aria.