Is there OR operator in GQL?

一世执手 提交于 2019-12-12 13:53:25

问题


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)

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.

Thanks.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/11872654/is-there-or-operator-in-gql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!