Re: [sqlalchemy] query with HAVING COUNT doesn't work as expected

2015-08-03 Thread jurie . horneman
Thanks! That solved it. I'm a JOIN newbie, so I didn't realize left join and outer join were the same thing. J. On Monday, August 3, 2015 at 5:08:44 PM UTC+2, Ladislav Lenart wrote: Hello. pgAdmin query uses LEFT JOIN whereas SQLAlchemy query uses (inner) JOIN. Replace .join(...)

Re: [sqlalchemy] query with HAVING COUNT doesn't work as expected

2015-08-03 Thread Ladislav Lenart
On 3.8.2015 17:24, jurie.horne...@gmail.com wrote: Thanks! That solved it. I'm a JOIN newbie, so I didn't realize left join and outer join were the same thing. Well, in that case this might be of some use to you... SQL: * JOIN is short for INNER JOIN. * LEFT JOIN is short for LEFT OUTER

[sqlalchemy] query with HAVING COUNT doesn't work as expected

2015-08-03 Thread jurie . horneman
I am using Python 2.7, SQLAlchemy 0.9.3, and PostgreSQL 9.4. This: session.query(self.db.recording_table.c.id).\ join(self.db.frame_table, self.db.recording_table.c.id == self.db.frame_table.c.recording_id).\ group_by(self.db.recording_table.c.id).\

Re: [sqlalchemy] query with HAVING COUNT doesn't work as expected

2015-08-03 Thread Ladislav Lenart
Hello. pgAdmin query uses LEFT JOIN whereas SQLAlchemy query uses (inner) JOIN. Replace .join(...) with .outerjoin(...) in your SQLAlchemy query. HTH, Ladislav Lenart On 3.8.2015 16:48, jurie.horne...@gmail.com wrote: I am using Python 2.7, SQLAlchemy 0.9.3, and PostgreSQL 9.4. This: