我有两个类:问题和答案。一个问题可能有0个或多个答案。如何选择没有答案的问题,在sqlalchemy
class Question(Base):
__tablename__ = "questions"
answers = relationship('Answer', backref='question',
primaryjoin="Question.id==Answer.question_id")
class Answer(Base):
__tablename__ = "answers"
现在我想找到所有的问题都没有答案,怎么做呢?
我想:
Session.query(Question).filter('count(Question.answers)==0').all()
这是不正确。什么是正确的?
你得到什么错误讯息? – miku 2010-09-01 09:27:54