![](/img/trans.png)
[英]Python: Find method to match similar but not identical names from two data frames
[英]MySQL - Match two tables contains HUGE DATA and find the similar data
我的SQL中有兩個表。 表1包含許多數據,但表2包含大量數據。
這是我使用Python實現的代碼
import MySQLdb
db = MySQLdb.connect(host = "localhost", user = "root", passwd="", db="fak")
cursor = db.cursor()
#Execute SQL Statement:
cursor.execute("SELECT invention_title FROM auip_wipo_sample WHERE invention_title IN (SELECT invention_title FROM us_pat_2005_to_2012)")
#Get the result set as a tuple:
result = cursor.fetchall()
#Iterate through results and print:
for record in result:
print record
print "Finish."
#Finish dealing with the database and close it
db.commit()
db.close()
但是,這需要很長時間。 我已經運行了1個小時的Python腳本,但它仍然沒有給我任何結果。
請幫我。
在兩個表中,您是否都對發明標題有索引? 如果沒有,則創建它:
ALTER TABLE auip_wipo_sample ADD KEY (`invention_title`);
ALTER TABLE us_pat_2005_to_2012 ADD KEY (`invention_title`);
然后將您的查詢合並為一個不使用子查詢的查詢:
SELECT invention_title FROM auip_wipo_sample
INNER JOIN us_pat_2005_to_2012 ON auip_wipo_sample.invention_title = us_pat_2005_to_2012.invention_title
讓我知道您的結果。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.