Jump to content

Comparing 2 tables mysql php


Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.