I have two tables with four columns each. Both may contain duplicate rows. I want to store matched entries in one table, while unmatched entries in another table. Here is the code I am trying, But not getting the desired output.
<?php
$con=mysqli_connect("localhost","root","","truck");
// Check connection
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sqlA="select date, truckno, bagscount from vendor";
$sqlB="select date, truckno, bagscount from truck";
$resultA=mysqli_query($con,$sqlA);
$resultB=mysqli_query($con,$sqlB);
$objA= mysqli_fetch_all($resultA,MYSQLI_NUM);
$objB= mysqli_fetch_all($resultB,MYSQLI_NUM);
$i=0;
$j=0;
while ($i<=(mysqli_num_rows($resultA)-1)){
if ($objA[$i][0]=$objB[$j][0] && $objA[$i][1]=$objB[$j][1] && $objA[$i][2]=$objB[$j][2]){
$i++;
echo "row ". $i. " matches". $j. "<hr>";
$j=0;
}
else
{
echo "not matched!";
$j++;
}
}
?>