[web2py] Re: sql query

2015-09-16 Thread Laurent Lc
Thank you for your qick answer. Ok i understand. Yes it works if use: for row in dbRH(dbRH.test.login=="Laurent").select(): firstname = row.firstname but the problem is that i would to use the var "auth.user.username" for my request and i don't know how to do Le mercredi 16 septembre 2015

[web2py] Re: sql query

2015-09-16 Thread Mirek Zvolský
I don't know what SQLField() means, I use Field() instead. The variable loginsession is defined at the python level. SQL level will nothing know about it. So you run really the SQL command: "SELECT ... WHERE login=loginsession;". Try same command in MySQL manager, it will not work because

[web2py] Re: sql query

2015-09-16 Thread Dave S
On Wednesday, September 16, 2015 at 5:41:22 AM UTC-7, Laurent Lc wrote: > > Thank you for your qick answer. > Ok i understand. > Yes it works if use: > > for row in dbRH(dbRH.test.login=="Laurent").select(): > firstname = row.firstname > > > but the problem is that i would to use the var

[web2py] Re: SQL query to find all records which are not in another table

2014-11-11 Thread Vladimir Makarov
Hi, Leonel. Thank you for taking me to the right way. It works well: rows = db(~db.persons.id.belongs(db()._select(db.tbl.person))).select() And I don't use dots in table names. On Monday, November 10, 2014 10:56:17 PM UTC+3, Leonel Câmara wrote: You can use belongs. You ask for those

[web2py] Re: SQL query to find all records which are not in another table

2014-11-10 Thread Leonel Câmara
You can use belongs. You ask for those that do not belong. http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#belongs something like tbl_person = db()._select(db['tbl.person'].id) db(~db.persons.id.belongs(tbl_person)).select() Do you actually have dots in your

[web2py] Re: SQL Query Help Using DAL

2011-06-24 Thread Massimo Di Pierro
I am guessing, I have not tried it mfrom = db.messages.with_alias('mfrom') mto = db.messages.with_alias('mfrom') db(db.auth_user).select(db.auth.user.first_name, db.auth_user.last_name, mfrom.id.count(), mto.id.count(),

Re: [web2py] Re: SQL Query Help Using DAL

2011-06-24 Thread David J.
Thanks I will try now. On 6/24/11 3:27 PM, Massimo Di Pierro wrote: I am guessing, I have not tried it mfrom = db.messages.with_alias('mfrom') mto = db.messages.with_alias('mfrom') db(db.auth_user).select(db.auth.user.first_name, db.auth_user.last_name, mfrom.id.count(),

Re: [web2py] Re: SQL Query Help Using DAL

2011-06-24 Thread David J.
Massimo; Thanks, this sort of works; The numbers seem off but this gives a good starting point; One other thing I would like to extend the table to include on other field 'mtype' which would be a value of 'text' or 'media', If I wanted to extend the query to use the previous query and

[web2py] Re: SQL Query Help Using DAL

2011-06-24 Thread Massimo Di Pierro
You can replace mfrom.on(mfrom.from==db.auth_user.id) with mfrom.on((mfrom.from==db.auth_user.id)(mfrom.type=='text')) and the same with the mto. On Jun 24, 3:06 pm, David J. da...@styleflare.com wrote: Massimo; Thanks, this sort of works; The numbers seem off but this gives a good

Re: [web2py] Re: SQL Query Help Using DAL

2011-06-24 Thread David J.
Got it thanks I think I tried but perhaps I did not use the right syntax I think I tried (mfrom.from==db.auth_user.id mfrom.type=='text') But I think it has to be logically separate (mfrom.from==db.auth_user.id)(mfrom.type=='text') On 6/24/11 4:28 PM, Massimo Di Pierro wrote: You can