我已经苦苦挣扎了很长时间,但我就是想不出来。
我有一个包含3列的表格,其中2列包含名称,第三列包含这些名称之间的Damerau Levensthein距离(http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance)。
每一列都包含所有名称,这意味着autor1列中出现的所有名称也在autor2列中出现。因此,我需要两倍于所需行数的行,只是autor1和autor2列交换了位置。
例如,第3行等于第1行,只是autor列被交换了位置,第2-4行也是如此。我该如何编写查询以省略这些“重复项”?
id-|------autor1----|------autor2-----| dld
1 -| Abel, Gustav -| Abel, Gustave | 1
2 -| Abel, Gustav -| Abele, Gustav | 1
3 -| Abel, Gustave| Abel, Gustav --| 1
4 -| Abele, Gustav | Abel, Gustav -| 1
结果:
|------autor1----|------autor2-----| dld
| Abel, Gustav -| Abel, Gustave | 1
| Abel, Gustav -| Abele, Gustav | 1
AND yti.id > yto.id
这部分代码救了我的命。这可以防止重复。感谢您提供的解决方案。 - Ahmet DAL