2017-03-16 55 views
-5

写的SQL写我有以下表情况:在列表属性

一个博客包含了很多帖子。 A 有一个作者

我想编写一个SQL查询:返回作者“Janet”至少有3篇帖子的所有唯一博客;

我不知道如何做到这一点,因为我通常使用EntityFramework。任何帮助都会很棒。

**编辑

我尝试这样做:

SELECT auth.name 
FROM Blog blo 
LEFT JOIN Auth auth 
WHERE blo.authname = "janet" 
+3

作业?添加示例表格数据和预期结果 - 以及格式化文本。同时向我们展示您当前的查询尝试! – jarlh

+1

为什么你不这样做? – Jens

回答

1

Select distinct Blogs from tblblogs,tblposts,tblauthor where tblblogs.id=tblposts.blogid and tblposts.id=tblauthor.postid and tblautor.name='Janet' group by blogs having count(tblposts.id)>=3

这是一个粗略的查询,因为你没有提到的表结构。如果你想更详细的说明,请点名表结构