Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
CREATE TABLE `question` ( `id` int unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `published_date` datetime, `moderated` tinyint(1) unsigned NOT NULL DEFAULT 0, `deleted` tinyint(1) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`id`), INDEX `idx` (`published_date`, `moderated`, `deleted`) ); CREATE TABLE `comment` ( `id` int unsigned NOT NULL AUTO_INCREMENT, `material_id` tinyint(1) unsigned NOT NULL, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`), INDEX `material_id_ix` (`material_id`) ); explain SELECT `question`.* FROM `question` WHERE `question`.`deleted` = 0 AND `question`.`moderated` = 0 AND `question`.`published_date` > 0 AND NOT EXISTS (SELECT `id` FROM `comment` WHERE `question`.`id` = `comment`.`material_id`) ORDER BY `question`.`published_date` DESC LIMIT 15;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear