GQL中的OR条件返回错误,为什么?
当我在GQL中使用“或”条件时,出现了一个错误信息,内容是“BadQueryError: 解析错误:在符号OR处预期没有其他符号”。这是为什么呢?
db.GqlQuery("Select * from vendor where access='public' OR organisation_id='"+ orgid +"'")
1 个回答
3
GQL does not have an OR operator. However, it does have an IN operator,
which provides a limited form of OR.
vendors=vendor.all()
pub_vendors = vendors.filter("access = ","public")
vendors=vendor.all()
org_vendors = vendors.filter("organisation_id = ",orgid)
results = pub_vendors.extend(org_vendors)
文档上明确说明GQL没有“或”操作符。
你可以这样做……执行两个查询,然后把结果合并起来……