我一直在迁移网上商店。这样做的公司做错了事,我想自己修复。
问题是:
我有2个来自旧网上商店的表1(我们称其为A
)和一个来自新商店的表(我们称其为B
)。
现在,简短说明需要从table A
复制到table B
。 table A
中的列名称为meta_description
,而table B
中的列名称为description_short
。但我不想复制并完成。因为当我这样做时,一切都不会井然有序。因为两个表的排序方式不同。
我到这为止:
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO pskd_product_lang (description_short)
VALUES ($desc)";
// use exec() because no results are returned
$conn->exec($sql);
echo "New record created successfully";
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
其中$desc
在此处制作:
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM oc_product_description";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table><tr><th>ID</th><th>Name</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
$name = $row["name"];
$desc = $row["meta_description"];
echo "<tr><td>".$name."</td><td>".$desc."</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
$conn->close();
您可以看到目标table (B)
被称为pskd_product_lang
我尝试将来源table (A)
称为oc_product_description
是语句和我在互联网上发现的许多其他东西,但是没有用...
如果有人可以帮助我或指出正确的方向,我将不胜感激!
预先感谢