Multiple UPDATE table pdo php mqsql


Multiple UPDATE table pdo php mqsql

我从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));

更新代码。Miss look some变量

将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,这是需要的。