当前位置: 动力学知识库 > 问答 > 编程问答 >

php - InnerJoin not showing any output while it shows output without innerJoin

问题描述:

so I'm working on an assignment for school and I've run into a bit of an odd issue.

So, essentially what happens is, if I use the code

$mysqli = mysqli_connect("localhost", "root", "", "database3");

$sql = "SELECT * FROM review

INNER JOIN admin

ON review.adminID=admin.adminID

ORDER BY review.reviewDate DESC LIMIT 3";

$result = mysqli_query($con, $sql) or die(mysqli_error($con));

This is the output

However, when I remove the InnerJoin this is the output:

 $mysqli = mysqli_connect("localhost", "root", "", "database3");

$sql = "SELECT * FROM review

ORDER BY review.reviewDate DESC LIMIT 3";

$result = mysqli_query($con, $sql) or die(mysqli_error($con));

?>

How would I resolve this?

网友答案:

Hard to tell without seeing your table data or the code that calls the adminFirstName, which I assume is a call to the field within the row returned after the join.

As jarlh said, your first step would be to try a different join to see if there are any matches at all. If you tried that and got nowhere, it is most likely:

The adminID field on review is not the same structure as the adminID field on the admin table. Check your table fields ('show create table admin' and same for review). Are the adminID fields both integers? Same container size (usually 11 on a auto-increment), both signed or both unsigned? Both names spelled correctly, Etc.

If they are a match, then check the obvious - are there actually any exact id matches in the two tables?

分享给朋友:
您可能感兴趣的文章:
随机阅读: