SELECT *
FROM cars AS T1
WHERE
EXISTS
(
SELECT * FROM Imperfections as T2
WHERE T1.uid = T2.uid AND imperfection = 1
)
AND EXISTS
(
SELECT * FROM Imperfections as T2
WHERE T1.uid = T2.uid AND imperfection = 2
);
from: 
http://dba.stackexchange.com/questions/28431/many-to-one-subselection-in-single-query


I have tried following but it not perfect that the subquery is plain sql 
not pydal:


from gluon.sql import SQLXorable as Expression, SQLQuery
db(Expression(db, "exists(select id FROM Imperfections WHERE T1.uid = 
T2.uid AND imperfection = 1)") & ...).select(...)


Can you help?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to