Consider following are my two tables of DB and contents in them are being fetch to an array via mysql_fetch_array($result)
:
Table 1 Table 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 | +-------+-------------------------+ +-------+------------------------------+
Now what I wanna do is to create a new array and compare the two arrays where similar_text($array1,$array2) percentage = 90 or above
and then sort the third array by asc onbehlaf of USD.
Something like in terms of PHP + mysql
Select * from Table1,Table2 where similar_text(Table1.model,Table2.model) > 90 order by Table1.USD asc
Note: I tried LEVENSHTEIN in mysql but its extremely slow Especially when there are 1000 of rows in your table
So output should look like the following:
+-------+-------------------------------------------------------------+ | 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 | +-------+-------------------------+ +-------+------------------------------+
Kindly let me know how can i make it happen?