views:

674

answers:

3

In MySQL it's like:

select * from table1 where column1 in ('a','b','c');

how to do that in GQL?

+5  A: 

It seems everything is in here

Itay Moav
how did you find this?search GQL on google?
Shore
Go to the main app engine site (http://code.google.com/appengine/). click on "docs" then click on "storing data" (under the python heading). then click "gql reference".
Peter Recore
"how did you find this?search GQL on google": yes
Itay Moav
+4  A: 

You can use one of the following

  result = db.GqlQuery("Select __key__ from model where column in ('a','b','c')")

or

   result = db.GqlQuery("Select * from model where column in ('a','b','c')")

The call with _ _ key _ _ is a lot more efficient than the * call on the appengine. It uses less datastore calls as well as less CPU to do it.

AutomatedTester
How to make column support full-text search,could you provide a demo?
Shore
as far as I know you can't. Full-Text Searching requires a lot of work from a database. SQL Server for example breaks it up and stores it on the filesystem for faster indexing. TextProperty() and StringProperty() columns can indexed while Blob style columns cant. This means that it will need a lot of work to reduce down the data to do searching on it.
AutomatedTester
But gae supports full-text search,so there must be a solution.
Shore
AutomatedTester
Those APIs have hided the true things that are going on,it's the datastore that support full-text search,right?So there must be a syntax for datastore to index and do full-text search,but Google intended not to publish that document yet.
Shore
Yea it looks like that but if you do use it they will hit your counters quite hard. Full-Text Searching is quite a hard thing to do with normal data structures.
AutomatedTester
+1  A: 

Just exactly as you described it works fine - but beware, IN queries are implemented in the Python API, and translate to multiple underlying datastore queries. If there's another way you can fetch the data, I'd highly recommend using that instead.

Nick Johnson