GAE sql (GQL) correct format?

折月煮酒 提交于 2019-12-11 06:46:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!