What's the equivalent SQL's IN()? Or, how do I compare against a list of values?

2 views
Skip to first unread message

Waleed

unread,
May 6, 2008, 9:36:42 PM5/6/08
to Google App Engine
How do I do the equavalent of this SQL in GQL?

SELECT * FROM books WHERE isbn IN ('12345', '6789', 'ABCD', 'EFGH')

keyvez

unread,
May 6, 2008, 10:43:43 PM5/6/08
to Google App Engine
That I am afraid would not be possible or atleast easy in GQL coz. GQL
doesn't support the OR operator.

http://code.google.com/appengine/docs/datastore/gqlreference.html

Waleed

unread,
May 6, 2008, 11:31:29 PM5/6/08
to Google App Engine
Right. I'm aware that GQL doesn't support OR. But this seems like a
basic requirement that many applications might need. Do you know if
this is a beta version limitation that's expected to be solved later?

The only way I can think of around this now is to loop in my code and
run the query once for each value. This seems like an inefficient way,
though. Especially if I have a list of 100 or more values to check
against. Can you think of a better workaround?

Brett Morgan

unread,
May 6, 2008, 11:42:37 PM5/6/08
to google-a...@googlegroups.com
You can set things up so that you are retrieving a set of entities by
their key, in which case you can use get(list_of_keys).

http://code.google.com/appengine/docs/datastore/functions.html#get


On Wed, May 7, 2008 at 11:36 AM, Waleed <waleed....@gmail.com> wrote:
>
> How do I do the equavalent of this SQL in GQL?
>
> SELECT * FROM books WHERE isbn IN ('12345', '6789', 'ABCD', 'EFGH')
>
>
> >
>

--

Brett Morgan http://brett.morgan.googlepages.com/

Reply all
Reply to author
Forward
0 new messages