开发者

Run sql like "OR" query on appengine

How can I run the equivalent of this query:

"select * from users where username='john' or email='john@email.com';

on appengine? I know appengine doesn't support the 开发者_运维技巧"OR" but has "IN" just not sure how to use it for such a query.


This question gives an example of using 'IN' as an 'OR' equivalent. However, as noted in the comments, GAE will treat 'IN' like multiple queries and is generally a bad idea, especially when querying on many list values.

Your best bet is often to perform the separate queries yourself and combine them programmatically.

EDIT: As pointed out, using an IN filter won't work anyway for your specific example.


You cannot do that in one query in Appengine. You can do two querys and combine the two results.You should do something like this to achieve the above query

  result_1 = users.all().filter("username = ","john").fetch(100)
  result_2 = users.all().filter("email = ",'john@email.com').fetch(100)
  results = result_1.extend(result_2)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜