1

When i use the OR condion in GQL it return error messege tht "BadQueryError: Parse Error: Expected no additional symbols at symbol OR . Why?

db.GqlQuery("Select * from vendor where access='public' OR organisation_id='"+ orgid +"'")
Nijin Narayanan
  • 2,269
  • 2
  • 27
  • 46

1 Answers1

3
    GQL does not have an OR operator. However, it does have an IN operator, 
which provides a limited form of OR.

Docs clearly says that GQL doesn't have an OR operator..

You could do something like this ..Make two queries and combine the results...

  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)
Abdul Kader
  • 5,781
  • 4
  • 22
  • 40
  • 3
    Your example would be an AND, and almost certainly isn't what OP wants. – Wooble Jun 02 '11 at 22:53
  • 1
    If the vendors have a datetime property, how would I sort 'results' by time using GQL (usually done with `ORDER BY time ASC/DESC`)? Unless there's a nifty trick, it seems unnecessarily complex to have to do it programmatically – benjammin Jul 24 '12 at 08:42
  • `AttributeError: 'Query' object has no attribute 'extend'`. You need to call `fetch` before you can `extend`. – OJFord Oct 03 '14 at 15:17