We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
题目链接:文章浏览 Ⅰ
此表的每一行都表示某人在某天浏览了某位作者的某篇文章。
请注意,同一人的 author_id 和 viewer_id 是相同的。
author_id
viewer_id
编写一条 SQL 查询以找出所有浏览过自己文章的作者,结果按照 author_id 升序排列。
create table views ( article_id int, author_id int, viewer_id int, view_date date ); insert into views (article_id, author_id, viewer_id, view_date) values (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'), (3, 4, 4, '2019-07-21'), (3, 4, 4, '2019-07-21');
select distinct author_id id from views where author_id = viewer_id order by id;
因为同一个人的 author_id 和 viewer_id 是相同的,所以直接筛选 author_id = viewer_id ,就能找出浏览过自己文章的作者了。
author_id = viewer_id
The text was updated successfully, but these errors were encountered:
No branches or pull requests
题目
题目链接:文章浏览 Ⅰ
此表的每一行都表示某人在某天浏览了某位作者的某篇文章。
请注意,同一人的
author_id
和viewer_id
是相同的。编写一条 SQL 查询以找出所有浏览过自己文章的作者,结果按照
author_id
升序排列。SQL:方法一
解析
因为同一个人的
author_id
和viewer_id
是相同的,所以直接筛选author_id = viewer_id
,就能找出浏览过自己文章的作者了。The text was updated successfully, but these errors were encountered: