| | 203 | The nested case: |
| | 204 | |
| | 205 | {{{ |
| | 206 | for id in ids: |
| | 207 | record1 = db(db.table1.id == id).select().first() |
| | 208 | if record1 and record1.some_attribute == some_value: |
| | 209 | record2 = db(db.table2.id == record1.some_key).select().first() |
| | 210 | if record2: |
| | 211 | ... |
| | 212 | }}} |
| | 213 | |
| | 214 | ...if there is nothing to else to do with the table1 records, try instead: |
| | 215 | |
| | 216 | {{{ |
| | 217 | query = (db.table1.id.belongs(ids)) & \ |
| | 218 | (db.table1.some_attribute == some_value) & \ |
| | 219 | (db.table2.id = db.table1.some_key) |
| | 220 | record2 = db(query).select(db.table2.ALL, limitby(0,1)).first() |
| | 221 | if record2: |
| | 222 | ... |
| | 223 | }}} |
| | 224 | |