How to do SQL inner queries through SQLAlchemy

70 Views Asked by At

Lets say I have two tables:

  • ticket with columns [id,date, userid] userid is a foreign key that references user.id
  • user with columns [id,name]

And I wish to perform the following query through sqlalchemy:

select ticket.id, user.name 
from
 (
   select * from ticket
   where ticket.date >= '2015-05-18'
 ) as ticket 
left join user on ticket.user_id=user.id

I am not quite sure how to perform inner queries through sqlalchemy. Any thoughts?

0

There are 0 best solutions below