php从多个表中选择reords并比较结果

时间:2017-05-17 14:11:14

标签: php mysql

第一个语句选择用户正在关注的所有用户,第二个语句选择用户的所有注释以及他们关注的所有其他用户,我正在尝试组合两个select语句:

$get_user = $user_data['username']; $get_following = mysqli_query($con,"SELECT * FROM follows WHEREfollower= '$get_user' ")

$query = mysqli_query($con,"SELECT * FROM posts WHERE username = '$followe' OR username = '$get_user' ORDER BY date_added DESC LIMIT 0,5 ");

我尝试使用以下代码,但只有当用户使用的用户超过人时才会提取单个用户:

$get_following = mysqli_query($con,"SELECT * FROM follows WHEREfollower= '$get_user' ");

$ffg = mysqli_fetch_assoc($get_following);

$ff = $ffg['follower'];

$query = mysqli_query($con,"SELECT * FROM posts WHERE username = '$ff' OR username = '$get_user' ORDER BY date_added DESC LIMIT 0,5 ");

请帮助解决这个问题,谢谢。

0 个答案:

没有答案