The SQL optimizer incorrectly alters the logic of a query that uses CTEs and nested JOIN operations. WITH `res` AS ( SELECT `t2`.`id`, CAST(IF(NOT `t3`.`id` IS NULL, 1, 0) AS BIGINT) AS `id_active`, ...
-- Creating a table CREATE TABLE Library ( book_id INT AUTO_INCREMENT PRIMARY KEY, //Unique ID for each book(auto increment) title VARCHAR(200) NOT NULL, //books ...