0
votes

i'm having some difficulty comparing two tables from an application i'm trying to do. I'm using Flask SQLAlchemy to query data.

[Table 1] - id : | title : | genre_id :

[Table 2] - id : | genre_id : | name :

So i want to compare genre_id from table 1 to table 2 and if there's a match i want return table 2 'name'.

Thanks!

1

1 Answers

0
votes

Perform a join

session.query(Table2, Table1).\
filter(Table2. genre_id ==Table1.genre_id).all()