I am currently making a project where at a certain condition, the content of TableA would be summarized and inserted into TableB, then a new row would be inserted into TableA. However, it seems that the statement I have created cannot be prepared in PHP, despite the actual query working fine in SQL. Can someone instruct me on what to do in order to fix this?
$insert = "INSERT INTO DATABASE.TableB(ColumnB2, ColumnB3, ColumnB4, ColumnB5)
SELECT DATE(MAX(ColumnA2)), MIN(ColumnA3), MAX(ColumnA3), AVG(ColumnA3)
FROM DATABASE.TableA
;
DELETE
FROM DATABASE.TableA
;
ALTER TABLE DATABASE.TableA AUTO_INCREMENT = 1
;
INSERT INTO DATABASE.Current_Level(ColumnA2, ColumnA3)
VALUES(CURRENT_TIMESTAMP, ?)
;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $insert))
{
echo "Error";
}
else
{
mysqli_stmt_bind_param($stmt, "d", $ColumnA2);
mysqli_stmt_execute($stmt);
}