GQL中有OR运算符吗? [英] Is there OR operator in GQL?

查看:147
本文介绍了GQL中有OR运算符吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道这是否在这里被问过。我看到几个关于喜欢运算符的问题,但我不知道如果这是我正在找。对不起我是一个noob在这。但是我从MySQL转移到Google App Engine,想知道GQL中是否有一个OR运算符与MySQL中的OR运算符类似。

I don't know if this has been asked here. I saw couple of questions on "like" operator but I'm not sure if that's I'm looking for. Sorry I'm a noob at this. But I am moving from MySQL to Google App Engine and was wondering if there was an OR operator in GQL similar to ones in MySQL.

基本上我想要实现的是通过用户名或电子邮件地址获取登录名。所以我的查询将是这样的。

Basically what I am trying to achieve is get the login on name via their username or email address. So my query would be something like this.

query = db.GqlQuery("SELECT * FROM mytable 
                     where username = :name 
                     OR email = :email 
                     AND password = :password",
                     name = user,
                     email = email,
                     password = pass1)

我意识到我可以执行两个查询,并检查每个查询的成功完成,并能够实现这一点,但我我只是想知道是否已经有一个可用的GQL。

I realize that I can perform two queries and check each query for their successful completion and be able to achieve this but I am just wondering if there is already one available in GQL.

感谢。

推荐答案

$ c> OR 与 GQL ;它只支持 IN ,对于特定属性,您可以将其视为有限形式的 OR

像你已经说过的,你唯一的选择是执行两个不同的查询并组合结果。

You can't do OR with GQL; it only supports IN that you can see as a limited form of OR for a specific property.
Like you've already said, your only option is to execute two different queries and combine the results.

如果你选择的语言是Java, Query.CompositeFilter ,您可以使用 OR 运算符来构造过滤器。

If your language of choice is Java, have a look to the Query.CompositeFilter which you can use to construct a filter using the OR operator.

这篇关于GQL中有OR运算符吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆