我有三个表(喜欢),(帖子)和(用户),并且在我的程序中我按用户ID获取帖子,而这样做我想要返回,如果我喜欢的帖子与否,我试着去做像这样
$query="SELECT post , users.name, users.profile_pic , users.uid , posts.likes , posts.comments , posts.createdAt , posts.pid,
IF('$uid' IN (SELECT uid FROM likes WHERE uid='$uid' AND pid=this.posts.pid), 1, 0) AS i_liked
FROM posts
INNER JOIN users
ON users.uid = posts.uid
WHERE posts.uid = '$uid' OR posts.uid
IN (SELECT users.uid
FROM friends
INNER JOIN users
ON users.uid=friends.ruid OR users.uid=friends.luid
WHERE accept=1 AND (friends.luid='$uid' OR friends.ruid='$uid') AND users.uid!='$uid')
ORDER BY posts.createdAt DESC
LIMIT $loaded_posts, 20";
但它显示“pid = this.posts.pid”
时出错答案 0 :(得分:0)
您需要使用this.posts.pid
更改posts.pid
。