我有两个表: TableA: id, StringA TableB: id, StringB
从 TableA 中获取所有行后,我想匹配尽可能接近 TableB 中的单词。我正在尝试做这样的事情:
c.execute('SELECT id, StringB FROM TableB WHERE StringB LIKE "'+stringa+'%" COLLATE NOCASE')
foundrows=c.fetchall()
if (len(foundrows)>0):
print 'Hmm. Which one...'
for foundrow in foundrows:
print 'looking for:'+stringa+' found:'+ foundrow[1]
这给了我类似的东西:
Hmm. Which one...
looking for:goo found:good
looking for:goo found:good 1
looking for:goo found:good 2
looking for:goo found:good 1 dk
looking for:goo found:good 2 dk
looking for:goo found:Good Friday
looking for:goo found:goose
looking for:goo found:Good Friday 1
looking for:goo found:good sport
looking for:goo found:good job
looking for:goo found:good morning
looking for:goo found:good night
looking for:goo found:goodbye 1
looking for:goo found:goodbye e
looking for:goo found:goodbye
我真正想做的是'SELECT id, StringB FROM TableB WHERE StringB CONTAINS WORD "'+stringa+'"
实现“包含单词”的最佳方法是什么?