下面是示例表:
1学生
studentID—主键
学生姓名
大学ID
2大学
学院ID—主键
学院名称
我想获得所有学生的关键价值观和所有大学的关键价值观
下面是sqlalchemy查询的示例。你知道吗
from example.database import dao
...
...
example = dao.query(students).\
join(colleges,
students.collegeID == colleges.collegeID).\
all()
但它没有collegeName数据。只有学生数据。
所以我不得不改变它。你知道吗
example = dao.query(students.studentID,
students.studentName,
stduents.collegeID,
colleges.collegeName).\
join(colleges, students.collegeID == colleges.collegeID).\
all()
如何在不指定所有所需密钥的情况下更轻松、更快地执行此操作。你知道吗
这将返回元组值列表:
相关问题 更多 >
编程相关推荐