Loading... # 文章浏览量 I ## 题目描述 表1: `Views` ```plaintext +---------------+---------+ | Column Name | Type | +---------------+---------+ | article_id | int | | author_id | int | | viewer_id | int | | view_date | date | +---------------+---------+ 此表没有主键, 每一行是某用户在某天浏览某篇文章的记录。 ``` 写一个查询语句,找出所有浏览过自己文章的作者。 返回结果表中的顺序无要求。 查询结果格式如下例所示。 ## 输入格式 ### 表结构 ```plaintext Views +------------+-----------+-----------+------------+ | article_id | author_id | viewer_id | view_date | +------------+-----------+-----------+------------+ | 1 | 3 | 5 | 2019-08-01 | | 1 | 3 | 6 | 2019-08-02 | | 2 | 7 | 7 | 2019-08-01 | | 2 | 7 | 6 | 2019-08-02 | | 4 | 7 | 1 | 2019-07-22 | +------------+-----------+-----------+------------+ ``` ## 输出格式 ### 输出样例: ```plaintext +------+ | id | +------+ | 7 | +------+ ``` ### 题目分析 ```markdown 在这道题目中,我们需要筛选出浏览过自己文章的作者。可以通过判断`author_id`是否等于`viewer_id`来实现。 ``` ### 代码实现 ```sql select distinct author_id as id from Views where author_id=viewer_id order by id; ``` 请根据以上描述和示例来完成题目。 最后修改:2024 年 06 月 21 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏
1 条评论
独特的构思和新颖的观点,让这篇文章在众多作品中脱颖而出。