我想做一個PDO連接查詢來獲取用戶點,但我收到此錯誤:語法錯誤或訪問衝突:1066不是唯一表/別名:'點'' 我猜我需要做點像p1那樣的東西,但是我對新的別名並不確定如何編碼。我似乎無法找到堆棧溢出的相關示例。PDO別名代碼錯誤
<?php
$pointresults = $dbh->prepare("SELECT
wp_users.ID,
points.points
FROM points
LEFT JOIN points on points.ID = wp_users.ID
WHERE (wp_users.ID = $user_ID)");
$pointresults->bindParam(':wp_users.ID', $user_ID, PDO::PARAM_INT);
$pointresults->bindParam(':points.ID', $ID, PDO::PARAM_INT);
$pointresults->execute();
$pointrow = $pointresults->fetchAll(PDO::FETCH_ASSOC);
?>
<?php echo $pointrow[0]['points'] ?>
變化'FROM points'爲'FROM wp_users'? – stealthyninja
擺脫了錯誤!雖然我看不到結果。那是因爲我的echo聲明代碼? – Cary5000