比较两个数组并对WRT USD进行排序

时间:2012-11-18 10:59:57

标签: php mysql

请考虑以下是我的两个DB表,其中的内容是通过mysql_fetch_array($result)获取到数组:

表1 表2

+-------+-------------------------+      +-------+------------------------------+
| USD    | Model                   |     | USD   | Model                        |
+-------+-------------------------+      +-------+------------------------------+
| 700    | iPad 2 WiFi 16GB        |      | 710     | iPad2 WiFi 16GB              |
| 400    | iPhone 4S 16GB          |      | 450     | iPhone4S 16GB                |
| 250    | iPod Touch(4th Gen)8GB  |      | 200     |iPod Touch 4th Generation 8GB |
+-------+-------------------------+      +-------+------------------------------+

现在我要做的是创建一个新数组并比较similar_text($array1,$array2) percentage = 90 or above的两个数组,然后按美元的asc onbehlaf对第三个数组进行排序。 像PHP + mysql

这样的东西

Select * from Table1,Table2 where similar_text(Table1.model,Table2.model) > 90 order by Table1.USD asc

注意:我在mysql中尝试了LEVENSHTEIN,但速度极慢尤其是当你的表中有1000行时

因此输出应如下所示:

+-------+-------------------------------------------------------------+
| USD1    | Model1                         USD2   | Model2            |
+-------+----------------------------------------+------------------------------+
| 250    | iPod Touch(4th Gen)8GB  |      | 200     |iPod Touch 4th Generation 8GB |
| 400    | iPhone 4S 16GB          |      | 450     | iPhone4S 16GB                |
| 700    | iPad 2 WiFi 16GB        |      | 710     | iPad2 WiFi 16GB              |
+-------+-------------------------+      +-------+------------------------------+

请告诉我如何才能实现?

0 个答案:

没有答案