the only argument you can pass to count() is a fieldname, so it will count
using DISTINCT

>>> db(db.products.id>0)._count('id')
'SELECT count(DISTINCT id) FROM products WHERE (products.id > 0)'

Left Joins are Row objects, so this object is a fetched rows from database,
there no way (that I know) to do a left join in a Query or Set objects.

len(db().select(.....))  # seems to be the only way.

To minimize the db charge, do the counte by less columns not using .ALL (*)

total = len(db().select(db.products.id,
                                 db.orders.id,
                                 left=db.orders.on(db.products.id==
db.orders.id)
                               )
                 )


On Sun, Jul 3, 2011 at 12:32 PM, weheh <[email protected]> wrote:

> To the best of my knowledge, count() doesn't take an argument, such as
> left. I would like to be proven wrong. If so, then how do we count if
> there's a left join, except by doing a select and then a
> len(db(query).select(...left=[...]))? Seems like it should be able to
> do db(query).count(left=[...]).




-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]

Reply via email to