案例是,这里是SQL:
sql = "select p.name State, c.name City, d.name District from "\
"info p, info c, info d "\
"where p.id= '%s' and c.id = '%s' and d.id = '%s'" %(State, City, District)
我想用sqlachemy替换它,就像这样:
session.query(info.label('State').filter(info.id == State),\
query(info.label('City')).filter(info.id == City),\
info.label('District')).filter(info.id == District)
当然,上面的代码有语法错误,我的意思是我想使用一个query()
,但是像query(table1, table2, table3...)
这样的几个段匹配一个或多个filter()
:
query(t1, t2, t3).filter(t1.0, t1.1, t2, t3)
我不知道它是否有上述陈述?