GAE sql (GQL) correct format?

430 Views Asked by At

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 ?

2

There are 2 best solutions below

0
David Underhill On BEST ANSWER

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.

0
SRK On

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.