Frank
Frank

Reputation: 31090

GAE sql (GQL) correct format?

My sql looks like this :

SELECT * FROM Contact_Info_Entry where Name.length < 18

[ Got incorrect GQL syntax error message ]

"Name" is a String in the Contact_Info_Entry.java class, I'm not familiar with sql, let alone GQL, if I want to select all names less than 18 characters long, what's the correct GQL syntax to use ?

Upvotes: 1

Views: 400

Answers (2)

SRK
SRK

Reputation: 1040

GQL does not provide any function like length.

In your app engine application, you have to find length of name and make one field named length.

Then, you can fire a query directly on the length column.

Upvotes: 0

David Underhill
David Underhill

Reputation: 16253

You can't filter by a field's length with GQL.

However, you could achieve this if you denormalize your model and include the length of Name as a field in your model.

Upvotes: 3

Related Questions