你能告訴我這個查詢有什麼問題嗎?我一直在尋找了將近一個小時,但我看不出任何語法錯誤..PDO查詢語法錯誤
$query = $database->connection->prepare(
"SELECT
n.from_id AS friend_id,
n.type AS type,
n.created_date AS time,
u.user_profile_picture AS profile_picture,
u.user_firstname AS friend_firstname,
u.user_lastname AS friend_lastname,
FROM notifications n INNER JOIN users u ON u.user_id = n.from_id
WHERE n.to_id = :user_id AND n.checked = 1");
$query->bindValue(':user_id', $user_id, PDO::PARAM_STR);
$query->execute();
這是錯誤:
Uncaught exception 'PDOException' with message
'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM notifications n INNER JOIN users u ON u.user_id = n.from_id WHERE n.to_id =' at line 8' in
刪除查詢前的逗號FROM – splash21
錯字錯誤標誌! – asprin