Details
Description
DROP TABLE IF EXISTS `foobar`;
CREATE TABLE IF NOT EXISTS `foobar` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(45) NULL )
ENGINE = InnoDB;
INSERT INTO `foobar` (`name`) VALUES ('A');
INSERT INTO `foobar` (`name`) VALUES ('B');
INSERT INTO `foobar` (`name`) VALUES ('C');
INSERT INTO `foobar` (`name`) VALUES ('D');
INSERT INTO `foobar` (`name`) VALUES ('E');
SELECT
`SubQuery`.`Static` AS `Random`,
`SubQuery`.`Name`
FROM (
SELECT
RAND() AS `Random`,
1 AS `Static`,
`Name`
FROM `foobar`
) AS `SubQuery`
ORDER BY
`SubQuery`.`Random`,
`SubQuery`.`Name`;
When executing in MySQL the result is sorted correctly at random. In MariaDB the result is incorrectly sorted alphabetically by name. When renaming the first alias (`SubQuery`.`Static` AS `Random`) to `Random2`, the sorting is correct in MariaDB, too.
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Thanks for the report. As a workaround, you can try setting optimizer_switch=derived_merge=off.