How to write a query that can find me all item_number start with a certain value ?
For instance there are item_numbers like these :
123_abc
123_xyz
ierireire
321_add
999_pop
My current query looks like this :
"select from "+PayPal_Message.class.getName()+" where item_number == '"+Item_Number+"' order by item_number desc"
What's a query look like that can return all item_numbers start with "123_" ?
Quoted from the google app engine docs:
Tip: Query filters do not have an explicit way to match just part of a string value, but you can fake a prefix match using inequality filters:
db.GqlQuery("SELECT * FROM MyModel WHERE prop >= :1 AND prop < :2", "abc", u"abc" + u"\ufffd")
This matches every MyModel entity with a string property prop that begins with the characters abc
. The unicode string u"\ufffd"
represents the largest possible Unicode character. When the property values are sorted in an index, the values that fall in this range are all of the values that begin with the given prefix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With