首页 > 代码库 > Working with Data Sources 9
Working with Data Sources 9
1. One to many relations:
one value in column in table one related to several values in the column in table two. In this case, we need to be very clear that who is "one" and who is "many":
cursor = conn.cursor()
query =‘‘‘SELECT ceremonies.year,nominations.movie # select target column we want to fit into the query
FROM nominations # select table from the ‘one‘ table
INNER JOIN ceremonies #select table from the ‘many‘ table
ON ceremonies.id == nominations.ceremony_id # select revelent column
WHERE nominations.nominee == "Natalie Portman"; # select conditions we would like to query
‘‘‘
cursor.execute(query)
portman_movies = cursor.fetchall()
2.
Working with Data Sources 9
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。