Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7894779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:28:55+00:00 2026-06-03T07:28:55+00:00

I have class Question(db.Model): wording = db.StringProperty(required=True) class Answer(db.Model): question = db.ReferenceProperty(Question, required=True) userId

  • 0

I have

class Question(db.Model):
    wording = db.StringProperty(required=True)

class Answer(db.Model):
    question = db.ReferenceProperty(Question, required=True)
    userId = db.IntegerProperty(required=True)

And I want to

SELECT * FROM Question WHERE Id NOT IN (
       SELECT QuestionId FROM Answer WHERE userId = 1)

How to do that in GQL

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:28:56+00:00Added an answer on June 3, 2026 at 7:28 am

    GQL doesn’t have a NOT IN statement, so unfortunately, it’s not possible to do exactly what you want.

    If the total set of userIds is small, you can reverse your query to use the IN statement. For instance:

    SELECT * FROM Answer WHERE userId IN ('2', '3')
    

    Note that this is executing a subquery for each value in the IN statement and you are allowed a maximum of 30 queries per GQL statement.

    If the total set of Answers where userId = 1 is small, you can select all Answers and filter out the ones from userId = 1 in your own code. However, if the set of Answers from userId 1 is large, this will not be particularly efficient.

    Finally, rather than computing either of these queries on-demand, you can use a cron to precompute the results (and store them to the datastore and/or memcache). When your code requires the results of one of these queries, you can load the cached result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
I have a two classes: public class Question { public IList<Answer> Answers { get;
I want to have a django model like this: class Model(models.Model): string = models.CharField()
I have models similar to the following: class Band(models.Model): name = models.CharField(unique=True) class Event(models.Model):
Question 1: I am playing around with EF4 and I have a model class
The domain is like this: class Poll(db.Model): question = db.StringProperty() ... class Choice(db.Model): poll
I have a general OO design question that stems from a Hibernate Model. Example
I have the following model (dumbed down for this question): public class Student {
I have a Question class: class Question { public int QuestionNumber { get; set;
I have a class called Question that has a property called Type. Based on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.