我正在填充一个正在从其他2个表中获取ID来显示其信息的表,例如,交货带有汉堡包和盒子,但是用户可以不带盒子地注册交货,仅向汉堡包注册。当我将INNER JOIN
SELECT
从DB
中获取数据时,它将返回0结果,因为没有框,并且我试图比较不存在的ID。然后,它会化成桌子。
SELECT
entrega_telemovel.*,
telemovel.id_telemovel,
telemovel.nroserie,
nro_telemovel.numero_telemovel,
nro_telemovel.id_nrotelemovel,
funcionarios.id_funcionario,
funcionarios.nome
FROM entrega_telemovel
INNER JOIN telemovel
ON entrega_telemovel.telemovel = telemovel.id_telemovel
INNER JOIN nro_telemovel
ON nro_telemovel.id_nrotelemovel = entrega_telemovel.numero_telemovel
INNER JOIN funcionarios
ON funcionarios.id_funcionario = entrega_telemovel.funcionario_entrega
ORDER BY funcionarios.nome;
在此查询中,entrega_telemovel.telemovel=telemovel.id_telemovel
的值像我上面给出的示例一样为空。因此,查询返回0个结果。我该如何解决?
Edit1:这是我的entrega_telemovel.telemovel
页面。
PHP
0){?><div class="card-body">
<div class="table-responsive">
<table id="devv" class="cell-border row-border compact nowrap" width="100%" cellspacing="0">
<thead>
<tr>
<th style="border: 1px solid gray" class="text-center">Funcionario</th>
<th style="border: 1px solid gray" class="text-center">Telemovel</th>
<th style="border: 1px solid gray" class="text-center">Nº Telemovel</th>
<th style="border: 1px solid gray" class="text-center">Data Entrega</th>
<th style="border: 1px solid gray" class="text-center">DEVOLUÇÃO </th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_assoc($busca)) {
?>
<tr>
<td class="text-center"><?php echo $row['nome'];?></td>
<td class="text-center"><?php echo $row['telemovel'];?></td>
<td class="text-center"><?php echo $row['numero_telemovel'];?></td>
<td class="text-center"><?php echo $row['data_entrega'];?></td>
<td class="text-center">
<form action="delete_entregatelemovel.php" method="post">
<input type="hidden" name="excluir_id" value="<?php echo $row['id_entrega'];?>">
<button type="submit" name="excluir_btn" class="btn btn-dark"> DEVOLUÇÃO</button>
</form>
</td>
</tr>
<?php
}
?>
</tbody>
</table>