CREATE TABLE `table1` ( `column` INT(5) );
INSERT INTO `table1` (`column`) VALUES (1),(2),(4),(5),(8);
CREATE TABLE `table2` ( `column` INT(5) );
INSERT INTO `table2` (`column`) VALUES (1),(3),(5),(7);
(SELECT `column`
FROM `table1`
WHERE `column` NOT IN (
SELECT `column` FROM `table2`
)
)
UNION
(SELECT `column`
FROM `table2`
WHERE `column` NOT IN (
SELECT `column` FROM `table1`
)
)
Expected result: 2, 3, 4, 7, 8
Obtained result: 2, 3, 4, 7, 8