john_cocarcea Posted June 5, 2008 Share Posted June 5, 2008 I've created here a querry that is comparing 2 tables type string "Title" when they are equals this code works code: -------------------------------------------------------------------------------- $sqlselect="UPDATE Table1 INNER JOIN Table2 ON Table1 .Title = Table2.Title SET Table1.id1=Table2.id1, Table1.id2=Table2.id2 "; $add = mysql_query($sqlselect, $local) or die(mysql_error()); -------------------------------------------------------------------------------- The problem is here, when i wanted to compare aprox values of this Fields , to compare two fields after it is comapring the whole Title and to substarct one word after every try to compare until it finds first solution and tis is for every row from table For the beginning i've tried with arrays something like this: code: -------------------------------------------------------------------------------- $select1 = "SELECT Title FROM Table2"; $res=mysql_query($select1, $local) or die(mysql_error()); while($row = @mysql_fetch_array($res)) { $spat=" "; $den_aray = explode($spa, $row['Title']); $den=''; for($i = count($den_aray)-1; $i >=0; $i--) { $den=$den.' '.$den_aray[$i]; $sql = "UPDATE Table1 INNER JOIN Table2 ON Table1.Title LIKE '$den%' SET Table1.id1=Table2.id1, Table1.id2=Table2.id2 WHERE Table1.Title = '$den% '"; $arr= mysql_query($sql,$local); } -------------------------------------------------------------------------------- can you help me to improvize some code to compare with aproximation or something like that or to compare somehow this 2 tables Quote Link to comment https://forums.phpfreaks.com/topic/108821-comparing-2-tables-mysql-php/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.