我目前有两个使用 PDO / MySQL 的查询:
$sql = "UPDATE permissions SET valid = 'N' WHERE perm_desc = :perm_desc";
$sth = $this->db->prepare($sql);
$sth->bindParam(':perm_desc', $perm_desc);
$sql2 = "UPDATE role_perm SET valid = 'N' WHERE perm_id = :perm_id";
$sth2 = $this->db->prepare($sql2);
$sth2->bindParam(':perm_id', $perm_id);
我想知道将这些结合起来是否更有意义,类似于:
$sql = "UPDATE permissions, role_perm
SET permissions.valid = 'N', role_perm.valid = 'N'
WHERE permissions.perm_desc = :perm_desc AND role_perm.perm_id = :perm_id";
我很难理解 JOIN,有些人说它们更快,而另一些人说它们更慢。什么是最好的解决方案?