python - SQLalchemy: joining one table on two columns -


i have join 2 tables, first table contains 2 reverences second. e.g. first table owns columns start_id , end_id. second table contains positions. how can join them in way have access start , end values. here have tried:

    endp = aliased(positions)     startp = aliased(positions)     trans_data = self.atomic_db.session.query(one, endp, startp                                               ).join(         endp,         one.start_id == startp.id).join(source_level,         one.end_id == endp.id).values(         one.id, endp.value ,         startp.value) 

t

your joins not ordered right, should write:

endp = aliased(positions) startp = aliased(positions) trans_data = self.atomic_db.session.query(one, endp, startp)\     .join(endp, one.end_id == endp.id)\     .join(startp, one.start_id == startp.id)\     .values(one.id, endp.value ,startp.value) 

also, did want update or query results? if latter - not need ".values"


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -