I want to change the status
of a single order by selecting its requisition_id
where the status
matches a specific keyword.
But it keeps showing me this error "You can't specify target table for update in FROM clause"
UPDATE order_info
SET status ='Approved'
WHERE requisition_no IN (SELECT requisition_no FROM order_info WHERE status = 'not approved')
What can I do to fix it?
EDIT- I've included the PHP code as well
while ($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['requisition_no'] . "</td>";
echo "<td>" . $row['desig'] . "</td>";
echo "<td>" . $row['deptt'] . "</td>";
echo "<td>" . $row['type'] . "</td>";
echo "<td>" . $row['make'] . "</td>";
echo "<td>" . $row['quantity'] . "</td>";
echo '<form method="post" action="status.php">'; /*Redirects to status.php to change the status (using diff. page because i'm a hopeless kid, who doesnt want to learn new ways of simplifying things)*/
echo "<td>" . $row['status'] . "<br/>";
if($row['status']=='Approved' || $row['status']=='Under Procurement'){//does nothing
}
/*Here, using a submit button*/
else { echo '<input type="submit" name="status" value="Approve"></td>';
$_SESSION['rno'] = $row['requisition_no'];}
echo '</form>';