Hello

   I am joining one table with itself so I am using alias as:

----------------------------
alias_usuarios1 = aliased(Usuario)
alias_usuarios2 = aliased(Usuario)

usuarios = DBSession.query(alias_usuarios1,
alias_usuarios2.nombre).filter(alias_usuarios1.resellers_id ==
alias_usuarios2.id)
----------------------------

All works ok except when I try to count how many rows I'd got. If I
apply count() to previous query I get following SQL code:


----------------------------
SELECT count(1) AS count_1
FROM (SELECT usuarios.id AS usuarios_id, usuarios_1.nombre AS
usuarios_1_nombre
FROM usuarios, usuarios AS usuarios_1, usuarios AS usuarios_2
WHERE usuarios_2.resellers_id = usuarios_1.id) AS anon_1
----------------------------

It is joining three tables instead two to make de JOIN. Is there any
way to mend it?

Regards

-- 
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