Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/04/2010, 10:51
benjaminvera
 
Fecha de Ingreso: junio-2008
Mensajes: 101
Antigüedad: 15 años, 10 meses
Puntos: 0
Dudas con JOIN, 2 nombres iguales en campos de diferentes tablas cómo diferenciarlo?

Tengo lo siguiente:

Código PHP:
Ver original
  1. $result_1 = mysql_query("select correo,lista_paises.opcion,lista_estados.opcion,mes,anio,fecha_solicitud,message,autorizacion
  2. from dco.Modificar_key join lista_paises on dco.Modificar_key.nomb_cen=lista_paises.id
  3. join lista_estados on dco.Modificar_key.nomb_plan=lista_estados.id;");
  4.  
  5. echo "<TABLE BORDER=2>";
  6.     echo "<table class=\"art-article\" width=\"1324px\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  7.     echo "<tbody>";
  8.     echo "<tr>";
  9.     echo "  <th>Correo</th>";
  10.     echo "  <th>Pais</th>";
  11.     echo "  <th>Estado</th>";
  12.     echo "  <th>Mes</th>";
  13.     echo "  <th>A&ntilde;o</th>";
  14.     echo "  <th>fecha_solicitud</th>";
  15.     echo "  <th>IP</th>";
  16.     echo "  <th>Hostname</th>";
  17. //  echo "  <th>message</th>";
  18.     echo "  <th>autorizacion</th>";
  19.     echo "</tr>";
  20. while ($myrow = mysql_fetch_array($result_1))
  21. {
  22. echo "<TR><TD name=correo>".$myrow['correo']."</td>[<td name=paises>".$myrow["opcion"]."</td>";
  23. echo "<TD name=estados>".$myrow["opcion"]."</td><TD name=mes>".$myrow['mes']."</td>";
  24. echo "<td name=anio>".$myrow["anio"]."</td><TD name=fecha_solicitud>".$myrow["fecha_solicitud"]."</td>";
  25. echo "<TD name=IP>".$myrow['IP']."</td><td name=hostname>".$myrow["hostname"]."</td>";
  26. echo "<TD><a href=\"viewdb.php?id=".$myrow[id]."&firstname=".$myrow[firstname]."\">View</a></tr>";
  27. }
  28. echo "</TABLE>";

Tengo la siguiente descripción:

Código MySQL:
Ver original
  1. mysql> describe lista_paises;
  2. +--------+-----------------+------+-----+---------+-------+
  3. | Field  | Type            | Null | Key | Default | Extra |
  4. +--------+-----------------+------+-----+---------+-------+
  5. | id     | int(3) unsigned | NO   | PRI | 0       |       |
  6. | opcion | varchar(60)     | NO   |     | NULL    |       |
  7. +--------+-----------------+------+-----+---------+-------+
  8. 2 rows in set (0.01 sec)
  9.  
  10. mysql> describe lista_estados;
  11. +----------+-----------------+------+-----+---------+----------------+
  12. | Field    | Type            | Null | Key | Default | Extra          |
  13. +----------+-----------------+------+-----+---------+----------------+
  14. | id       | int(5) unsigned | NO   | PRI | NULL    | auto_increment |
  15. | opcion   | varchar(60)     | NO   |     | NULL    |                |
  16. | relacion | int(3) unsigned | NO   | MUL | 0       |                |
  17. +----------+-----------------+------+-----+---------+----------------+
  18. 3 rows in set (0.01 sec)

Mi problema radica que que cuando llamo a Lista_paises.opcion en la funcion de

while ($myrow = mysql_fetch_array($result_1))
{
<td name=paises>".$myrow["opcion"]."</td>";
}

solo me jala la información de lista_estados.opcion....

Cómo le hago para diferenciar $myrow['opción'] tanto de lista_estados.opcion y de lista_paises.opcion


Ya probe con: .$myrow["lista_estados.opcion"]. y .$myrow["lista_paises.opcion"]. y esto NO funciona