多个更新 table pdo php mysql

Multiple UPDATE table pdo php mqsql

我从 this 问题中 Ifran 的回答中得到了灵感。但我得到这个 #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 任何建议表示赞赏

$stmt9 = $dbh - > prepare("UPDATE student_info AS t1 ,
                                student_address AS t2 ,
                                student_course AS t3 ,
                                student_parentinfo AS t4,
                                student_references AS t5 ,
                                student_status AS t6 
                            SET t1.status = :status, 
                                t2.status = :status,
                                t3.status = :status,
                                t4.status = :status,
                                t5.status = :status,
                                t6.status = :status 
                            WHERE t1.pin = :pin,
                                t2.pin = :pin,
                                t3.pin = :pin,
                                t4.pin = :pin,
                                t5.pin = :pin,
                                t6.pin = :pin 
                            AND t1.status = :active,
                                t2.status = :active,
                                t3.status = :active,
                                t4.status = :active,
                                t5.status = :active,
                                t6.status = :active");

$stmt9 - > execute(array(':status' => $notactive, ':pin' => $pin, ':active' => $propertystatus));

更新了代码。想念变数

将WHERE子句中的所有逗号改为AND:

$stmt9 = $dbh - > prepare("UPDATE student_info AS t1 ,
                                student_address AS t2 ,
                                student_course AS t3 ,
                                student_parentinfo AS t4,
                                student_references AS t5 ,
                                student_status AS t6 
                            SET t1.status = :status, 
                                t2.status = :status,
                                t3.status = :status,
                                t4.status = :status,
                                t5.status = :status,
                                t6.status = :status 
                            WHERE t1.pin = :pin AND
                                t2.pin = :pin AND
                                t3.pin = :pin AND
                                t4.pin = :pin AND
                                t5.pin = :pin AND
                                t6.pin = :pin
                            AND t1.status = :active AND
                                t2.status = :active AND
                                t3.status = :active AND
                                t4.status = :active AND
                                t5.status = :active AND
                                t6.status = :active");

此外,在您的 execute 调用中,您有 :id,它未在查询中使用,但没有 :pin,这是需要的。