PHP - Consultar datos en 3 tablas diferentes.

 
Vista:
Imágen de perfil de Diego Armando

Consultar datos en 3 tablas diferentes.

Publicado por Diego Armando (1 intervención) el 10/03/2017 18:58:27
Buenos dias. Tengo el siguiente problema para saber si me pueden ayudar:

Estoy diseñando un software de mensajeria certificada; ya tengo listo el tema de Reparto a Mensajeros, Entregas de Mensajeros y Devoluciones de Mensajeros.

Cada Opcion tiene su tabla independiente, el valor en comun que tienen es el numero de guia.


Las tablas que tengo son:

entregas (Donde se suben las Entregas)
devoluciones (Donde se suben las devoluciones)
subir_guias (Donde se suben los repartos)

El total de la base de datos se sube a la tabla subir_guias (numero_guia, destino, direccion... etc)
En la tabla entregas solo se sube el numero_guia y su estado OK
En la tabla devoluciones solo se sube el numero_guia y su estado (Intento Entrega, Rehusado, No hay quien reciba.. etc)

Necesito hacer una consulta que muestre las numero_guia que no esten en la tabla entregas o en la tabla devoluciones en un rango de fechas, es decir, que me muestre en un listado los numero_guia que no esten en las tablas entregas y devoluciones.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<div class="titulospaginas">
	<h2>Guias Pendientes</h2>
   </div>
   		<div class="formulario">
            <form id="frmPendientesMensajero" name="frmPendientesMensajero" method="POST" action="/index.php">
            <table width="600" border="0" cellspacing="5">
            <tr>
                <td align="left" width="200">Elija un rango de Fechas</td>
                <td>Inicio <input name="fechainicio" type="text" id="fechainicio" value="Elija una fecha" size="10" class="tcal"/></td>
                <td>Fin <input name="fechafin" type="text" id="fechafin" value="Elija una fecha" size="10" class="tcal"/></td>
            </tr>
            <tr>
                <td align="left" width="200"></td>
                <td><input name="consultarpendientes" id="consultarpendientes" type="submit" value="Consultar Pendientes" /></td>
            </tr>
            </table>
			</form>
 
      <br /><br />
  <table border="1" align="left" bordercolor="#FF6600" width="1170" style="table-layout:fixed">
      <tr>
        <td bgcolor="#FF660" width="50"><center><font face="arial" color="white" size="-1">FECHA SUBIDA</font></center></td>
        <td bgcolor="#FF660" width="40"><center><font face="arial" color="white" size="-1">NOMBRE CLIENTE</font></center></td>
        <td bgcolor="#FF660" width="40"><center><font face="arial" color="white" size="-1">CODIGO<BR />PROCESO</font></center></td>
        <td bgcolor="#FF660" width="80"><center><font face="arial" color="white" size="-1">NUMERO GUIA</font></center></td>
        <td bgcolor="#FF660" width="80"><center><font face="arial" color="white" size="-1">DESTINATARIO</font></center></td>
        <td bgcolor="#FF660" width="80"><center><font face="arial" color="white" size="-1">DIRECCION</font></center></td>
        <td bgcolor="#FF660" width="50"><center><font face="arial" color="white" size="-1">CIUDAD</font></center></td>
        <td bgcolor="#FF660" width="30"><center><font face="arial" color="white" size="-1">CICLO</font></center></td>
        <td bgcolor="#FF660" width="50"><center><font face="arial" color="white" size="-1">MENSAJERO</font></center></td>
        <td bgcolor="#FF660" width="50"><center><font face="arial" color="white" size="-1">RUTA</font></center></td>
      </tr>
  <?php
    while ($fila=mysql_fetch_array($rst_informe))
    {
  ?>
        <tr>
          <td><div align="right"><font face="arial"><?php echo $fila['fecha_subida']; ?>&nbsp; </font></div></td>
          <td><div align="right"><font face="arial"><?php echo $fila['nombre_cliente']; ?>&nbsp; </font></div></td>
          <td><div align="right"><font face="arial"><?php echo $fila['codigo_proceso']; ?>&nbsp; </font></div></td>
          <td><div align="right"><font face="arial"><?php echo $fila['numero_guia']; ?>&nbsp; </font></div></td>
          <td><div align="right"><font face="arial"><?php echo $fila['nombre_destinatario']; ?>&nbsp; </font></div></td>
          <td><div align="right"><font face="arial"><?php echo $fila['direccion_destinatario']; ?>&nbsp; </font></div></td>
          <td><div align="right"><font face="arial"><?php echo $fila['ciudad_destinatario']; ?>&nbsp; </font></div></td>
          <td><div align="right"><font face="arial"><?php echo $fila['ciclo']; ?>&nbsp; </font></div></td>
          <td><div align="right"><font face="arial"><?php echo $fila['mensajero']; ?>&nbsp; </font></div></td>
          <td><div align="right"><font face="arial"><?php echo $fila['ruta']; ?>&nbsp; </font></div></td>
        </tr>
  <?php
    }
  ?>
 
    </table>
 
      <br />
</div>

tabla-subir-guias
tabla-entregas
tabla-devoluciones
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder