问题
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 ?
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/4986688/gae-sql-gql-correct-format