当内部联接值可能为null时如何填充表?

问题描述 投票:0回答:1

我正在填充一个正在从其他2个表中获取ID来显示其信息的表,例如,交货带有汉堡包和盒子,但是用户可以不带盒子地注册交货,仅向汉堡包注册。当我将INNER JOIN SELECTDB中获取数据时,它将返回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">
mysql sql
1个回答
0
投票
<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>
© www.soinside.com 2019 - 2024. All rights reserved.