[web2py] Re: query in DAL

2011-01-30 Thread Massimo Di Pierro
I still do not fully understand so I am making some assumptions. Moreover you use field names either plural (and to me make more sense singular) or not allowed (date). So... db.define_table('item',Field('name',format='%(name)s') db.define_table('stock',Field('item',db.item),Field('type')) db.defin

Re: [web2py] Re: query in DAL

2011-01-29 Thread beto (R3)
Hey Vasile: Cause I have more clauses based on the stock table that I haven't included in the original query. For example: SELECT date, count(items) FROM ( SELECT logs.date, logs.items FROM logs WHERE extract(year from logs.date) = 2010) GROUP BY date, items ) AS foo,

Re: [web2py] Re: query in DAL

2011-01-29 Thread Vasile Ermicioi
why do you need 'stock' table ? >> WHERE >> stock.items = foo.items

Re: [web2py] Re: query in DAL

2011-01-29 Thread beto (R3)
Hey Massimo: Let me try to explain it: End goal: Display the total amount of non-duplicated items inserted every date. I have the logs table that has many items that are inserted at a given date (item a, b, c, d, etc) . The problem is that the same item might get inserted several times at the sa

[web2py] Re: query in DAL

2011-01-29 Thread Massimo Di Pierro
Before we try write is? Can you explain it? There is a condition on stcok that seems a inner join but nothing is selected from the stock table. On Jan 28, 2:16 pm, "beto (R3)" wrote: > Hey guys: > > Is there a way to do this query in DAL? > > SELECT >     date, count(foo.items) > FROM > ( >