zoukankan      html  css  js  c++  java
  • 查询文章的最后回复时间

    表:id,title,postuser,postdate,parentid
                      准备sql语句:
                      drop table if exists articles;
                      create table articles(id int auto_increment primary key,title
                      varchar(50), postuser varchar(10), 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 a.title,a.postuser,(select max(postdate) from articles where parentid=a.id) reply from articles a where a.parentid is null;

  • 相关阅读:
    C# 关于爬取网站数据遇到csrf-token的分析与解决
    Nginx实现同一端口HTTP跳转HTTPS
    Console也要美颜了,来给Console添色彩
    程序员如何巧用Excel提高工作效率
    LeetCode每日一练(1-3)
    Json对象转Ts类
    JcApiHelper 简单好用的.Net ApiHelper
    .Net Core Mvc/WebApi 返回结果封装
    C#光盘刻录
    Orm框架开发之NewExpression合并问题
  • 原文地址:https://www.cnblogs.com/l1pe1/p/8931589.html
Copyright © 2011-2022 走看看