Re: count from multiple tables in a single query?

2017-06-01 Thread Melvyn Sopacua
On Wednesday 31 May 2017 12:13:48 'Abraham Varricatt' via Django users wrote: > If I want to get the total count from both tables it can be done like > this, > > author_count = Author.objects.count() > publisher_count = Publisher.objects.count() > > My concern is that this results in two

Re: count from multiple tables in a single query?

2017-05-31 Thread James Schneider
On Wed, May 31, 2017 at 3:01 PM, Alceu Rodrigues de Freitas Junior < alceu.freitas...@gmail.com> wrote: > Hi James, > > I'm curious... why dropping down from the ORM and doing a single query > wouldn't be portable? > > I understand that it would happen if you use some kind of stored procedure >

Re: count from multiple tables in a single query?

2017-05-31 Thread Alceu Rodrigues de Freitas Junior
Hi James, I'm curious... why dropping down from the ORM and doing a single query wouldn't be portable? I understand that it would happen if you use some kind of stored procedure in the DB, but I guess a single ANSI SQL would do it. Thanks! - Alceu Em 31/05/2017 17:29, James Schneider

Re: count from multiple tables in a single query?

2017-05-31 Thread 'Abraham Varricatt' via Django users
PM > *To:* Django users > *Subject:* count from multiple tables in a single query? > > > > Hello, > > Is it possible to get the count of entries from multiple tables in a > single query call? I'm looking at the official docs on aggregation and I > can't find a

RE: count from multiple tables in a single query?

2017-05-31 Thread Matthew Pava
@googlegroups.com] Sent: Wednesday, May 31, 2017 2:14 PM To: Django users Subject: count from multiple tables in a single query? Hello, Is it possible to get the count of entries from multiple tables in a single query call? I'm looking at the official docs on aggregation and I can't find anything

Re: count from multiple tables in a single query?

2017-05-31 Thread James Schneider
> > > If I want to get the total count from both tables it can be done like this, > > author_count = Author.objects.count() > publisher_count = Publisher.objects.count() > > My concern is that this results in two different queries to the database. > Can it be done with a single query call? > >

count from multiple tables in a single query?

2017-05-31 Thread 'Abraham Varricatt' via Django users
Hello, Is it possible to get the count of entries from multiple tables in a single query call? I'm looking at the official docs on aggregation and I can't find anything. For example assume I have the following 2 tables, class Author(models.Model): name = models.CharField(max_length=100)