Stu.Axon wrote:
>
> I tried this
> session\
>     .query(func.count(distinct(build.device_id)))\
>     .filter(channelbuild.channel_id == 9)\
>     .filter(build.in_icp == False)\
>     .scalar()
>
> It generated this sql:
>
> SELECT
>     count(DISTINCT backfill_build.device_id)
> AS
>     count_1
> FROM
>     backfill_build, backfill_channelbuild
> WHERE
>     backfill_channelbuild.channel_id = %(channel_id_1)s
> AND
>     backfill_build.in_icp = %(in_icp_1)s
> -- {'in_icp_1': False, 'channel_id_1': 9}

if you are querying from two tables, those tables must be joined together
somehow else you'll get a cartesian product.  you're looking to add
backfill_build.some_id=backfill_channelbuild.some_other_id here.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to