2017-03-16 96 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

這是一個粗略的查詢,因爲你沒有提到的表結構。如果你想更詳細的說明,請點名表結構