I have a select with a count on it. Count row is taken from another
related table so I can see how many items a user has. I want to filter
the results to select only those with items more than 5 let's say.

Sqlalchemy generates 2 queries for this. Placing a 'having' filter
gives an error but looking at the generated sql's the first query is
ok and working, only the second one gives an error. Can any1 say if
there's a way in forcing sqlqlchemy to only generate 1 query?

generated sql's:

SELECT (SELECT count(`items`.id) AS count_1
FROM `items`
WHERE `items`.user_id = user.id) AS `itemsCount`, user.id AS user_id
FROM user
HAVING itemsCount>5

SELECT count(1) AS count_1
    FROM user
HAVING itemsCount>5


and the error:


OperationalError: (OperationalError) (1054, "Unknown column
'itemsCount' in 'having clause'") 'SELECT count(1) AS count_1 \nFROM
user \nHAVING itemsCount>5' ()

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

Reply via email to