Ver Mensaje Individual
  #4 (permalink)  
Antiguo 10/02/2010, 07:00
quimfv
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 2 meses
Puntos: 574
Respuesta: Consulta a dos tablas

Código MySQL:
Ver original
  1. SELECT sbc.* , H2.id
  2. (SELECT F.*, max(H.fecha) UltimoHistorial
  3. FROM datos_form F LEFT JOIN historial H
  4. on F.id=H.id_form
  5. GROUP BY F.id) sbc
  6. LEFT JOIN historial H2
  7. ON sbc.UltimoHistorial=H2.fecha
  8. AND sbc.id=H2.id_form;


Ya...

Quim