我想从一个表 ( oldDataTable) 中选择一些列并插入到另一个表 ( newDataTable) 中。两者都在同一个数据库中。我试过了。如果我只选择一列它的工作原理。但如果我选择不止一列,则不会发生任何事情。
oldDataTable 有像这样的列
Name | Date | Voltage | Current | Power | RMS.
我只想选择像这样的列Name| Date| Power并将其插入到newDataTable. 当用户提交表单按钮时,我正在这样做。请任何帮助。
<?php
if (isset($_POST['submit'])){
include ("DBconnect.php");
$conn= mysqli_connect( $dbhost, $dbuser, $dbpass, $db );
if ($conn->connect_error){
die("Connection failed: " . $conn->connect_error);
}
else{
$insertNEQuery= "INSERT INTO newDataTable (Name, Date, Power) SELECT (Name, Date, Power) FROM oldDataTable WHERE ID = '2' ";
//it should be a bunch of rows. I have data for every one minute.
mysqli_query($conn, $insertNEQuery);
echo " data updated!";
$conn->close();
}
} else
echo " please click submit button!";
?>
```
慕姐4208626
大话西游666