Search code examples
google-app-enginegqldatastoregqlquery

Can a GQL query execute an order by over two or more kinds?


I have two entity kinds in my python GAE app - both with similar attributes - and I'd like to query both lists and order the result according to an attribute common to both kinds. So something along the lines of:

db.GqlQuery("SELECT * FROM Video1, Video2 ORDER BY views DESC").fetch(1000)

Can I do this in GQL directly?


Solution

  • No. You need to run two queries, one for each kind.

    Check out the GQL and GqlQuery class references.

    You can actually do a kindless query using db.GqlQuery('SELECT') to fetch everything. However, you can not filter or order it (other than by key).

    edit:

    You may want to check out PolyModel.