On Friday, February 9, 2018 at 5:26:35 PM UTC-8, Anthony wrote: > > Anyway, given your code, it looks like we would not expect any results in >>> the intersection of the two Rows objects, as the conditions of each query >>> are mutually exclusive (i.e., "waypoint" either equals X or Y). Of course, >>> if X == Y, then the two sets of Rows are identical, but I assume that isn't >>> generally the case. >>> >>> >> A segment row will only have one waypoint, but multiple segment rows may >> have the same parent run. I chose to make the run table very simple (and >> in particular, not to have a list of children), but the segment table >> points upward to the run. >> > > Your code doesn't show which columns are selected -- I suppose you are > saying the "waypoint" column is *not *selected. > > Anthony >
Well, here's the code actually being used, now that my home dev machine is able to reach the interwebs again. segq1 = db.segment.waypoint.contains(request.args[0]) segq2 = db.segment.waypoint.contains(request.args[1]) runs1 = db((db.run.id == db.segment.partof) & segq1).select("run.id", "run.description", "run.distance","run.duration", orderby = db.run.id|db.run .duration, distinct=True) runs2 = db((db.run.id == db.segment.partof) & segq2).select("run.id", "run.description", "run.distance","run.duration", orderby = db.run.id|db.run .duration, distinct=True) At this point in the code, I'm only interested in the waypoints as a link to the parent runs. The goal is to make a list of runs that have both waypoints as children. (That is, runs that have at least 2 segments, and one segment contains waypoint X and one segment contains waypoint Y.) That list will be displayed showing the run.id/s (as a link), the distance, and the duration. Clicking on an id will show the details of that run by selecting ALL the segments. Sample list of runs: run.id run.description run.distance run.duration > 17 Work to 73 mrg via PP 7.9 9.0 > 19 Work to Home by AVP 19.5 21.0 > 20 Work to 73 mrg by La Paz 7.7 12.0 > 21 Work to Home by La Paz 19.2 24.0 Sample for details of one run (sorry about the wrap): > segment run waypoint via > time odometer begins ends comments > 42 2017-05-29, Work to 73 mrg via PP Office AVP > 12:20:00 35.0 True False > 43 2017-05-29, Work to 73 mrg via PP Pacific Park Pacific > Park 12:21:00 36.5 False False > 44 2017-05-29, Work to 73 mrg via PP Moulton Oso > Parkway 12:24:00 38.4 False False > 45 2017-05-29, Work to 73 mrg via PP Cabot I-5 > 12:26:00 40.4 False False > 46 2017-05-29, Work to 73 mrg via PP 73S merge I-5 > 12:29:00 42.9 False True (I suppose I don't really need to display the IDs as well as the run "names", but it's useful during development) /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.