3
I’m trying to make a select
with inner join
. Rotating the select
in the phpmyadmin the ERROR that returns is this:
Column 'idusuario' in Where clause is ambiguous
<?php
$idusuario = $_GET['idusuario'];
$getCli=$pdo->prepare("SELECT * FROM enderecoUsuario INNER JOIN usuario
ON enderecoUsuario.idusuario = usuario.idusuario
WHERE usuario.idusuario=:idusuario");
$getCli->bindValue(":idusuario", $idusuario);
$getCli->execute();
while ($linha=$getCli->fetch(PDO::FETCH_ASSOC)) {
$idusuario = $linha['idusuario'];
$nome = $linha['nome'];
$sobrenome = $linha['sobrenome'];
$logradouro = $linha['logradouro'];
$bairro = $linha['bairro'];
$cidade = $linha['cidade'];
$uf = $linha['uf'];
$email = $linha['email'];
$return = array(
'idusuario' => $idusuario,
'nome' => $nome,
'sobrenome' => $sobrenome,
'logradouro' => $logradouro,
'bairro' => $bairro,
'cidade' => $cidade,
'uf' => $uf,
'email' => $email
);
}
echo json_encode($return);
?>
WHERE usuario.idusuario=:idusuario
– Caique Romero
This is because in joins between 2 or more tables there is a column with the same name. You should use the reference of which table to display.
– Marconi