drol55885602 2012-03-26 11:00
浏览 235
已采纳

PHP MySql - SELECT其中similar_text()> x

I have two tables called reference and list. Both have two fields: id and name.

reference:
ref_id, ref_name
1, john
2, georges
etc...

list:
lst_id, lst_name
1, steward
2, james
3, john
4, jones
5, georges
etc...

I would like to select the name from both tables where similar_text()>60. Here below the output I would like to have:

ref_name, lst_name, similar_text()
john, john, 100
john, jones, 67
georges, georges, 100

Note that steward and james should be left out as the similar_text() is below 60.

Hope someone can help. Thank you in advance for your relies. Cheers. Marc. Oh, by the way, I am open to better solutions to achieve my goal...

  • 写回答

2条回答 默认 最新

  • douzi1350 2012-03-26 11:21
    关注

    You will most likely need levenshtein in mysql. This will allow you to calculate the differences in strings.

    you could then do something like:

    SELECT ref_name, lst_name, LEVENSHTEIN_RATIO( ref_name, lst_name ) as textDiff
    FROM reference, list
    HAVING textDiff > 60;
    

    Or something similar.

    NOTE: When working on large datasets this will most definitely have performance issues.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂