PDO 更新不同的列相同的查询

PDO Updates diferent columns same query

你能告诉我我做错了什么吗?

我想在 MySQL DB

中使用 PDO 在一个查询中更新 02 个不同的表

这是我的代码:

            $dados = [
                'senha' => password_hash($_POST['senha'], PASSWORD_BCRYPT),
                'ativo' => '0',
                'email' => $_POST['email'],
            ];

            $sql = "
            UPDATE administradores, solicitacoes_reseta_senhas
            SET    senha = :senha, ativo = :ativo
            WHERE  email = :email and email = :email
            ";

            $stmt= $pdo->prepare($sql);
            $stmt->execute($dados);

这是我从 MySQL:

得到的错误
Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'email' in where clause is ambiguous

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'email' in where clause is ambiguous

表格结构下方:

CREATE TABLE IF NOT EXISTS `solicitacoes_reseta_senhas` (
  `id` int NOT NULL AUTO_INCREMENT,
  `email` varchar(250) NOT NULL,
  `token` varchar(250) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `data_expiracao` datetime NOT NULL,
  `ativo` int NOT NULL,
  `data_criacao` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `administradores` (
  `id` int NOT NULL AUTO_INCREMENT,
  `nome` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `sobrenome` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `email` varchar(120) DEFAULT NULL,
  `senha` varchar(150) NOT NULL,
  `apelido` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `sexo` varchar(15) DEFAULT NULL,
  `telefone_fixo` varchar(25) NOT NULL,
  `telefone_celular` varchar(25) NOT NULL,
  `data_nascimento` date DEFAULT NULL,
  `observacao` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `data_criacao` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `data_atualizacao` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `adm_atualizacao` int NOT NULL DEFAULT '0',
  `ativo` tinyint DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`,`ativo`)
) ;

感谢您的宝贵时间

使用别名

  $dados = [
            'senha' => password_hash($_POST['senha'], PASSWORD_BCRYPT),
            'ativo' => '0',
            'email' => $_POST['email'],
        ];

        $sql = "
        UPDATE administradores a, solicitacoes_reseta_senhas s
        SET    senha = :senha, ativo = :ativo
        WHERE  a.email = :email and s.email = :email
        ";

        $stmt= $pdo->prepare($sql);
        $stmt->execute($dados);