INNER JOIN 不起作用,我没有收到错误
INNER JOIN is not working, i do not get errors
$result = mysqli_query($conn,"SELECT * FROM table1 INNER JOIN `table2`
ON `table1`.`id`=`table2`.`id`;");
while ($row = mysqli_fetch_array($result) ){
echo 'name <textarea>'.$row["name"].'</textarea>';
}
在 LAb (wampserver) 上它的工作我得到了关于 "name" 的信息,但在真正的网站上我没有得到关于 "name" 的信息。
我不知道你想收集什么,但你可以使用下面的查询来获取记录。它会为你工作。
"Select t1.* from table1 t1 inner join table2 t2
ON t1.id=t2.id"
请检查连接,实时连接可能不同。还要删除 table2.id 之后的分号 (;)。可能是您的问题已解决
可能会出现一些错误但不显示。
首先我建议你检查连接:
$conn = mysqli_connect("$host", "$user "my_password", "$DBname");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
如果有效,请检查查询错误:
if($result = mysqli_query($conn,"SELECT * FROM table1 INNER JOIN `table2`
ON `table1`.`id`=`table2`.`id`;"))
{
while ($row = mysqli_fetch_array($result) ){
echo 'name <textarea>'.$row["name"].'</textarea>';
}
}
else echo($conn->error);
其他可能的原因可能是:
ON 子句
条件成立:
ON table1
.id
=table2
.id
或者应该是这样的?
`ON `table1`.`id`=`table2`.`rif_id`
在 table1
或 table2
中 select 没有数据
在live
数据库中,您是否检查过select中是否有数据?可能刚好忘记在live数据库中插入数据
此外,您是否尝试过在 PhpMyAdmin 中手动查询?
$result = mysqli_query($conn,"SELECT * FROM table1 INNER JOIN `table2`
ON `table1`.`id`=`table2`.`id`;");
while ($row = mysqli_fetch_array($result) ){
echo 'name <textarea>'.$row["name"].'</textarea>';
}
在 LAb (wampserver) 上它的工作我得到了关于 "name" 的信息,但在真正的网站上我没有得到关于 "name" 的信息。
我不知道你想收集什么,但你可以使用下面的查询来获取记录。它会为你工作。
"Select t1.* from table1 t1 inner join table2 t2 ON t1.id=t2.id"
请检查连接,实时连接可能不同。还要删除 table2.id 之后的分号 (;)。可能是您的问题已解决
可能会出现一些错误但不显示。
首先我建议你检查连接:
$conn = mysqli_connect("$host", "$user "my_password", "$DBname");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
如果有效,请检查查询错误:
if($result = mysqli_query($conn,"SELECT * FROM table1 INNER JOIN `table2`
ON `table1`.`id`=`table2`.`id`;"))
{
while ($row = mysqli_fetch_array($result) ){
echo 'name <textarea>'.$row["name"].'</textarea>';
}
}
else echo($conn->error);
其他可能的原因可能是:
ON 子句
条件成立:
ON
table1
.id
=table2
.id
或者应该是这样的?
`ON `table1`.`id`=`table2`.`rif_id`
在
中 select 没有数据table1
或table2
在
live
数据库中,您是否检查过select中是否有数据?可能刚好忘记在live数据库中插入数据
此外,您是否尝试过在 PhpMyAdmin 中手动查询?