所以我需要来自2个表格的信息,但是我的JOIN Mysqli不起作用,有人能告诉我这是什么问题吗? :/ 我是INNER JOIN的新手,所以我可能理解错误了x_x
if($stream = $mysqli->prepare("SELECT $title.message_id, $title.message, $title.likes, $title.dislikes, $title.poster, $title.date, $title.closed user.rank, user.posts, user.reputation FROM $title INNER JOIN User ON $title.poster = user.username ORDER BY message_id ASC")){
$stream->execute();
$stream->bind_result($message_id, $message, $likes, $dislikes, $poster, $date, $closed, $rank, $posts, $rep, $usnm);
while($stream->fetch()){
答案 0 :(得分:1)
您确定$title
已定义吗?你确定user
有大写吗?
SELECT *
FROM $title
INNER JOIN user
ON $title.poster = user.username
ORDER BY message_id ASC;
答案 1 :(得分:0)
您似乎错过了列之间的逗号:$title.closed<needs comma here> user.rank
答案 2 :(得分:0)
首先,你有一个失踪的昏迷:
$title.closed user.rank
并且,在您的查询中,表“user”应该用作“User”,并在内部联接中声明大写字母。内连接是错误的。
您应该始终通过联接表开始内连接条件:
WRONG
FROM $title INNER JOIN User ON $title.poster = user.username
GOOD
FROM $title INNER JOIN User ON User.username = $title.poster