我的问题是以下代码,数组的注释和评级区域应该在其中有一个注释,因为数据库历史表... ...
SELECT users.uid, users.username, history.user_id, history.comment, history.rating
FROM history
LEFT JOIN users
ON users.uid=history.user_id
WHERE history.book_id="$bid"
它返回:
Array ( [uid] => 3 [username] => Reign [user_id] => 3 [comment] => [rating] => )
答案 0 :(得分:4)
然后你想使用INNER JOIN
。 LEFT JOIN
将返回NULL
个值。
SELECT users.uid, users.username, history.user_id, history.comment, history.rating
FROM history
INNER JOIN users
ON users.uid=history.user_id
WHERE history.book_id="$bid"