Ver Mensaje Individual
  #8 (permalink)  
Antiguo 27/09/2015, 17:18
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 9 meses
Puntos: 774
Respuesta: Prolema con mysql foreign key

Código SQL:
Ver original
  1. SELECT total, patente, dni FROM(
  2. SELECT SUM(montodanio) total, patente FROM auto AS t1
  3. LEFT JOIN auxacc AS t2 ON (t1.patente=t2.patente)
  4. LEFT JOIN accidente AS t3 ON (t1.idacc=t3.idacc)
  5. ) AS total
  6. LEFT JOIN propietario AS t4 ON (t4.patente=total.patente)
  7. WHERE total>=(SELECT avg(montodanio) FROM accidente )

Seria algo asi :)
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me