the follow function is not working
public function matchingService() {
$stmt = mysqli_prepare($this->connection, "
INSERT INTO reusematching.matchedtable(user_idUser, productDetail_idProduct,Status,applyData)
SELECT waitinglist_user.user_idUser,
waitinglist_product.ProductDetail_idProduct,
productstatus,
waitinglist_user.waitinglistUser_applydata
FROM reusematching.waitinglist_user,
reusematching.waitinglist_product,
productinformation.productdetail,
productinformation.productstatus
where (waitinglistProduct_status = 1
and waitinglistUser_status = 1
and productCategroy_productCategroyID = waitinglistUser_applyProductType
and ProductDetail_idProduct = idProduct
and idStatus = waitinglistProduct_status);
SET SQL_SAFE_UPDATES=0;
DELETE FROM reusematching.waitinglist_user
WHERE Exists
(SELECT matchedtable.idMatchedTable
FROM reusematching.matchedtable
where matchedtable.user_iduser= waitinglist_user.user_idUser);
DELETE FROM reusematching.waitinglist_product
WHERE Exists
(SELECT matchedtable.idMatchedTable
FROM reusematching.matchedtable
where matchedtable.ProductDetail_idProduct
= waitinglist_product.ProductDetail_idProduct);
SET SQL_SAFE_UPDATES=1;
");
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
return null;
}
the flex shown
Server error MySQL Error – 1064: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near ‘DELETE FROM reusematching.waitinglist_user
WHERE Exists (SELECT matche’ at line 18
Why I have this error? and how to debug it.
The mysql driver in PHP does not allow multiple queries to be issued in a single query() call. This is true of both the old mysql and newer mysqli functions. This is a security measure to prevent some forms of SQL injection attacks.
You’ll have to split your hideously big query statement into multiple (smaller) individual queries: