假设以下表格
source(
id INT,
name VARCAHR
)
dest(
id INT,
name VARCAHR
)
source
表填充了id
和name
;并且dest
仅填充name
,id
设置为null
有必要更新dest
表,并设置id
id
,name
是source
UPDATE dest
SET dest.id = (
SELECT source.id, levenstein_ratio(dest.name, source.name) as similarity
FROM source
GROUP BY similarity HAVING similarity > 50
ORDER BY similarity DESC
LIMIT 1
).id
(由Levenstein距离计算)bin/nutch solrindex http://127.0.0.1:8983/solr/mycore crawl/crawldb -linkdb crawl/linkdb crawl/segments/20160913225018
表
为了更好地理解这是我理想的计划方式(查询有语法错误):
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 0);
如果没有重复功能,我无法进行任何合理的查询。
有办法吗?效率并不重要,但可以理解一些合理的解决方案
答案 0 :(得分:0)
你设置dest.id需要select中的一个返回值,所以你应该重构你的查询,例如:这样
UPDATE dest
SET dest.id = (
SELECT source.id
FROM source
GROUP BY levenstein_ratio(dest.name, source.name)
HAVING levenstein_ratio(dest.name, source.name) > 50
ORDER BY levenstein_ratio(dest.name, source.name) DESC
LIMIT 1
)