I have an application (used for comparing routes) with 2 tables relevant to this question. (Paraphrasing; code is at home, where the router jammed.)
db.define_table('run', Field('when', 'date'), Field('description', 'string)) db.define_table('segment', Field('waypoint', 'string'), Field('timeofday', 'time'), Field('odometer', 'decimal'), Field('partof', 'reference run')) I wanted to find the runs that had X as a waypoint and also had Y as a waypoint, so I looked at <URL:http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Combining-rows> and wrote: def fromto(): # not shown -- X and Y from request.vars q1 = db.segment.waypoint = X q2 = db.segment.waypoint = Y runs1 = db(run.id == segment.partof & q1).select(...,distinct=True) runs2 = db(run.id == segment.partof & q2).select(...,distinct=True) theruns = runs1 & runs2 print len(runs1) + len(runs2) + len(theruns) return ("runs" = theruns) For the first waypoints I tried, the print produced counts of 111 10 121 which is clearly NOT the intersection. (I have verified that theruns includes runs where Y is not included, and the page shows the Y runs at the end of the X runs (that is, appended).) If I go for union ('|' in line 7), the counts are 111 10 112. (1 Y run did not go through X). I add the "distinct=True" after the first attempt, in case multiple appearances of a row was confusing things. It made no apparent difference. I think this is on 2.14.6; I may be able to test newer web2py's tonight. Am I doing something wrong, or was there a hiccup in intersection? Dave S /dps -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.