[web2py] how to use startswith in query

2013-10-28 Thread Mark
Hello, I want to use startswith in a query like following, but it didn't work: db.person.name.startswith(db.student.name) What is wrong in this query? Is there a better way for it or a work around? Any help would be greatly appreciated. Thanks -- Resources: - http://web2py.com -

Re: [web2py] how to use startswith in query

2013-10-28 Thread Vinicius Assef
rows = db(db.person.name.startswith(John)).select() On Mon, Oct 28, 2013 at 1:50 PM, Mark czhang2...@gmail.com wrote: Hello, I want to use startswith in a query like following, but it didn't work: db.person.name.startswith(db.student.name) What is wrong in this query? Is there a better way

Re: [web2py] how to use startswith in query

2013-10-28 Thread Mark
Viniciusban, Thank you for the help. But I don't know if the name is John or whatever. I hope the name such as John can be fetched dynamically from another table (e.g. db.student). Now, I think maybe it is not possible. On Monday, October 28, 2013 3:04:29 PM UTC-4, viniciusban wrote: rows

Re: [web2py] how to use startswith in query

2013-10-28 Thread Vinicius Assef
Could you supply an example of what you intend to achieve, preferably a query? On Mon, Oct 28, 2013 at 5:17 PM, Mark czhang2...@gmail.com wrote: Viniciusban, Thank you for the help. But I don't know if the name is John or whatever. I hope the name such as John can be fetched dynamically from

Re: [web2py] how to use startswith in query

2013-10-28 Thread Mark
I have a equipment table contains different equipments with model numbers such as SVP701, SVP710, SVP755. Another lookup table contains their expected life time for model numbers such as SVP7 for 10 years, TPU3 for 20 years. I want the wildcard SVP7 match all SVP701, SVP710, SVP755, so that

Re: [web2py] how to use startswith in query

2013-10-28 Thread Niphlod
ok. there's clearly a mismatch between what you expect from what you're writing. db.table.field == 'something' db.table.field something db.table.field.startswith('something') db.table.field.contains('something') are what in DAL are called Queries. They turn out to be the WHERE part in

Re: [web2py] how to use startswith in query

2013-10-28 Thread Mark
Niphlod, Thank you very much for your detail answers. It seems that your new data model is better, and is the way to go. My old model may be fine for my small database using the OR. I may try both and compare. Thanks! On Monday, October 28, 2013 6:20:31 PM UTC-4, Niphlod wrote: ok. there's