Working with Data Sources 9
Posted 阿难的机器学习计划
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章