我有2个mysql表:
Customers(id,short_name,full_name, contact, address, amount)
old_customer_record(id, name, contact, address, amount)
并且在这种情况下,我有2000条以上的记录,我想确认所有旧客户都包含在新表中。
但是我不能直接检查,因为
我要为此做什么?还是有可能?我的代码如下,
for ($i=1; $i < 2000; $i++) {
$sql = "SELECT * FROM old_customers WHERE id = '$i'";
$result = $connect->query($sql);
if ($result->num_rows > 0) {
$row = $result->fetch_array();
$name = $row[1];
$sql1 = "SELECT * FROM customers WHERE short_name LIKE '%$name%'";
$result1 = $connect->query($sql1);
while ($row1 = $result1->fetch_array()) {
$output['data'][] = array(
$row1[0],
$row1[1],
$row1[2],
$row1[3],
$row1[4]
);
}
} // if num_rows
}
echo json_encode($output);
请帮助我,谢谢。
选择最适合比较表的列。我看到了最适合的姓名和联系方式。 Address
的格式可能不同,许多记录的金额可能相同(不是唯一的)。