在List属性上写一个SQL写

时间:2017-03-16 10:09:46

标签: sql

我有下表情况:

博客包含许多帖子。 帖子作者

我想写一个SQL查询:返回作者至少有3篇帖子的所有独特博客" Janet&#34 ;;

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

**编辑

我试过了:

Caused by: java.sql.SQLException: Io exception: Oracle Error ORA-12650
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) ~[ojdbc14-10.2.0.3.0.jar:Oracle JDBC Driver version - "10.2.0.3.0"]
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146) ~[ojdbc14-10.2.0.3.0.jar:Oracle JDBC Driver version - "10.2.0.3.0"]
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255) ~[ojdbc14-10.2.0.3.0.jar:Oracle JDBC Driver version - "10.2.0.3.0"]
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387) ~[ojdbc14-10.2.0.3.0.jar:Oracle JDBC Driver version - "10.2.0.3.0"]
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:439) ~[ojdbc14-10.2.0.3.0.jar:Oracle JDBC Driver version - "10.2.0.3.0"]
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165) ~[ojdbc14-10.2.0.3.0.jar:Oracle JDBC Driver version - "10.2.0.3.0"]
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35) ~[ojdbc14-10.2.0.3.0.jar:Oracle JDBC Driver version - "10.2.0.3.0"]
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801) ~[ojdbc14-10.2.0.3.0.jar:Oracle JDBC Driver version - "10.2.0.3.0"]
    at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:297) ~[ojdbc14-10.2.0.3.0.jar:Oracle JDBC Driver version - "10.2.0.3.0"]
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:221) ~[ojdbc14-10.2.0.3.0.jar:Oracle JDBC Driver version - "10.2.0.3.0"]
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:165) ~[ojdbc14-10.2.0.3.0.jar:Oracle JDBC Driver version - "10.2.0.3.0"]
    at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:92) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]

1 个答案:

答案 0 :(得分: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

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