Komunikat: "Column 'id' in field list is ambiguous"

0
$getUserId = $db->prepare("SELECT `id` FROM `members` AS a JOIN `cars` AS b ON a.id = b.id_user WHERE `username` = :userName");
$getUserId->bindValue(":userName", $_SESSION['user_login'], PDO::PARAM_STR);
if(!$getUserId->execute()){
    print_r($getUserId->errorInfo());
}

Zwraca mi:

Array ( [0] => 23000 [1] => 1052 [2] => Column 'id' in field list is ambiguous )

Co jest nie tak? :)

0

W obu tabelach masz kolumnę ID, musisz wskazać o którą konkretnie chodzi, tę z members, czy tę z cars

SELECT a.id FROM members AS a JOIN cars AS b ON a.id = b.id_user WHERE username = :userName;

1 użytkowników online, w tym zalogowanych: 0, gości: 1