sqlalchemy简单的内部联接

时间:2015-10-11 20:04:10

标签: python mysql sqlalchemy

我是sql炼金术的新手, 考虑您有以下两个表定义:

class Persons(Base):  
   __tablename__ = 'persons'  
   id = Column(INTEGER, primary_key =True)  
   first_name = Column(String(10))  
   last_name = Column(String(10))
   zip_code =  Column(Integer)  

 class Addresses(Base):   
  __tablename__ = 'addresses'  
   ad_id = Column(INTEGER, primary_key =True)  
   name = Column(String(10))  
   zip_id = Column(Integer, ForeignKey('persons.zip_code'))  

问题是如何对people.zip_code = addresses.zip_id以及上述定义进行内部联接?

由于

0 个答案:

没有答案