Nested query of sqlalchemy

for a correct sql nested query statement:

select * from flight where flight_num=any(select flight_num from ticket where user_email = "1234@qq.com")

how to write his sqlalchemy statement
my intention is: when a user takes a plane, there will be a record after buying a ticket-- there is a foreign key flight_num on the ticket ticket, ticket and the user"s user_email,. I want to log in by the user and query all the flight information according to the ticket owned by the user, that is, through the flight_num in ticket to query the list of aircraft details

.
Nov.03,2021

is about:

q = session.query(Ticket.flight_num).filter(Ticket.user_email == 'xxx@xxx.com')
r = session.query(Flight).filter(Flight.flight_num.in_(q))
Menu