我没有得到任何数据,而且我已经检查了我的爸爸哪个应该匹配
我有两张表,likes
和user_follow
我试图通过id绑定两个表。
表格 - 列
likes
- idlikes,iduser,information
user_follow
- iduser_follow,iduser_follower,iduser_following
$following = $dbh -> prepare("SELECT L.* FROM likes L JOIN user_follow F ON F.iduser_following = L.iduser WHERE F.iduser_follower = ?");
$following->execute(array($_SESSION['user_auth']));
while($row_following = $following->fetch(PDO::FETCH_ASSOC)){
$id_1 = $row_following['L.information']; // get id of user that i'm following
echo $id_1;
}
因此,如果我关注某人,我应该能够显示与我关注的任何人相关的信息。
我没有得到任何错误,它只是没有回应任何东西?
样本数据
user_follow
iduser_follow iduser_follower iduser_following
1 2 3
2 2 4
likles
idlikes iduser information
1 3 info1
2 3 info2
所以,我应该输出info1和info2,假设$ _SESSION ['user_auth'] = 2,是吗?
答案 0 :(得分:1)
SELECT b.*
FROM user_follow a
INNER JOIN likes b
ON a.iduser_following = b.iduser
WHERE a.iduser_follow = 'myuserID' AND
iduser_following = 'followingID'
并获取值
$id_1 = $row_following['information'];