I defined the following table: db.define_table('ntw_edge', Field('outID', 'reference vtx_vertex'), Field('inID', 'reference vtx_vertex'), Field('labelID', 'reference ntw_edge_label_set'), Field('networkkey', type='integer', default=1), migrate = False)
The database contains a.o. the following records: id outID inID labelID networkkey 1 1622 1456 6 1 2 1456 1622 6 2 3 1622 1473 6 1 4 1473 1622 6 1 5 1622 1456 8 1 6 1456 1622 8 1 I want to join inID on outID where the labelIDs are the same, resulting in: 1622 1456 6 1456 1622 6 1622 1473 6 1473 1622 6 1622 1456 8 1456 1622 8 and then join this with the vtx_vertex and ntw_edge_label_set tables. I created an alias: ntw_edge_alias In SQL the query would be: SELECT ... FROM ntw_edge INNER JOIN ntw_edge_alias ON ntw_edge.inID=alias_edge.outID WHERE ntw_edge.outID=1622 AND (ntw_edge.labelID=alias_edge.labelID) How do I code this in web2py? My attempts so far seem to interpret this code (ntw_edge.labelID=alias_edge.labelID) in the WHERE clause as a join, so the query returns too many records> KInd regards, Annet -- 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.