-- 创建表DROP TABLE IF EXISTS articles;CREATE TABLE articles( id INT AUTO_INCREMENT PRIMARY KEY, title VARCHAR(50), postuser VARCHAR(10), articles postdate DATETIME, parentid INT REFERENCES articles(id) );-- 插入数据库INSERT INTO articles VALUES(NULL,'第一条','张三','1998-10-10 12:32:32',NULL),(NULL,'第二条','张三','1998-10-10 12:34:32',NULL),(NULL,'第一条回复1','李四','1998-10-10 12:35:32',1),(NULL,'第二条回复1','李四','1998-10-10 12:36:32',2),(NULL,'第一条回复2','王五','1998-10-10 12:37:32',1),(NULL,'第一条回复3','李四','1998-10-10 12:38:32',1),(NULL,'第二条回复2','李四','1998-10-10 12:39:32',2),(NULL,'第一条回复4','王五','1998-10-10 12:39:40',1);-- 显示文章标题,发帖人、最后回复时间-- 知识点一:在Select 中循环嵌套使用 Select-- 知识点二:判断 null 用 isSELECT a.title , a.postuser , (SELECT MAX(b.postdate) FROM articles b WHERE b.id = a.id) AS replyFROM articles aWHERE a.parentid IS NULL;