Skip to content

Instantly share code, notes, and snippets.

@it-can
Last active July 2, 2019 17:00
Show Gist options
  • Save it-can/555a2ceb9f7a8336bae766fe2f758c84 to your computer and use it in GitHub Desktop.
Save it-can/555a2ceb9f7a8336bae766fe2f758c84 to your computer and use it in GitHub Desktop.
Mariadb 10.4.6 problem
CREATE TABLE `test_table` (
`age_from` tinyint(2) NOT NULL,
`age_to` tinyint(2) NOT NULL,
`gender` enum('M','V') NOT NULL,
`norm_min` float NOT NULL,
`norm_max` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `test_table`
ADD KEY `age_from` (`age_from`),
ADD KEY `age_to` (`age_to`),
ADD KEY `gender` (`gender`);
INSERT INTO `test_table` (`age_from`, `age_to`, `gender`, `norm_min`, `norm_max`) VALUES
(15, 19, 'M', 48, 100),
(20, 24, 'M', 50, 100),
(25, 54, 'M', 53, 100),
(55, 59, 'M', 52, 100),
(60, 64, 'M', 50, 100),
(65, 69, 'M', 48, 100),
(70, 74, 'M', 46, 100),
(75, 79, 'M', 44, 100),
(80, 84, 'M', 41, 100),
(85, 89, 'M', 37, 100),
(15, 19, 'V', 33, 100),
(20, 24, 'V', 34, 100),
(25, 54, 'V', 35, 100),
(55, 59, 'V', 33, 100),
(60, 64, 'V', 32, 100),
(65, 69, 'V', 29, 100),
(70, 74, 'V', 27, 100),
(75, 79, 'V', 24, 100),
(80, 84, 'V', 21, 100),
(85, 89, 'V', 18, 100);
// Query causing issues on mariadb 10.4.6, no results. Works on mariadb 10.3.16 (expecting row "(25, 54, 'M', 53, 100)")
SELECT * FROM test_table WHERE gender="M" AND (age_from <= 46 AND age_to >= 46)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment