首页 > 其他 > 详细

Working with Data Sources 9

时间:2016-11-22 09:49:13      阅读:207      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/kingoscar/p/6087826.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!