如果所有内容都相似,我想检查两个表

I want to check two tables if all their contents are similar

我想检查两个 table 的内容是否相似 并回显是或否相似度。 我的 PHP 脚本不工作:

<?php
$path = $_SERVER['DOCUMENT_ROOT'];
include($path."db.php");
$sql = "SELECT * 
        FROM thprtins";
$sqlt = "SELECT * 
        FROM thirdparty";

$result = $conn->query($sql);
$resultt = $conn->query($sqlt);
if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        $id = "" . $row["id"] . "";
        $expiry = "" . $row["expiry"] . "";
        $type = "" . $row["type"] . "";
        $financial = "" . $row["financial"] . "";
        $coid = "" . $row["coid"] . "";
        echo "$id.$expiry.$type.$financial.$coid<br>";
     }
}
if ($resultt->num_rows > 0) {
    while($rows = $resultt->fetch_assoc()) {
        $idd = "" . $rows["id"] . "";
        $expiryy = "" . $rows["expiry"] . "";
        $typee = "" . $rows["type"] . "";
        $financiall = "" . $rows["financial"] . "";
        $coidd = "" . $rows["coid"] . "";
        echo "$idd.$expiryy.$typee.$financiall.$coidd<br>";
    }
}
if ($result === $resultt) 
    echo "Two tables are similar"; 
else {
    echo "no Similarity ";
};
 ?>

我有一个主 table 和一个备份 table,我只是在某个地方更改了备份 table。如果两个table不相等,我想做均衡操作

虽然两行table的内容不同,但是输出结果是: 两个table相似

使用 MySQL CONCAT() 将每一行的所有列合并为一个字段,然后使用 GROUP_CONCAT()

将所有行合并为一行
$sql = "SELECT GROUP_CONCAT(CONCAT(`id`,',',`expiry`,',',`type`,',',`financial`,',',`coid`) SEPARATOR ',') AS `all_data` FROM thprtins";
$sqlt = "SELECT GROUP_CONCAT(CONCAT(`id`,',',`expiry`,',',`type`,',',`financial`,',',`coid`) SEPARATOR ',') AS `all_data` FROM thirdparty";
$result = $conn->query($sql)->fetch_assoc()['all_data'];
$resultt = $conn->query($sqlt)->fetch_assoc()['all_data'];
if ($result === $resultt) 
    echo "Two tables are similar"; 
else {
    echo "no Similarity ";
}