Southperry.net
A little MySQL help - Printable Version

+- Southperry.net (https://www.southperry.net)
+-- Forum: Social (https://www.southperry.net/forumdisplay.php?fid=14)
+--- Forum: Rubik's Cube (https://www.southperry.net/forumdisplay.php?fid=58)
+--- Thread: A little MySQL help (/showthread.php?tid=58979)



A little MySQL help - Manu - 2012-11-19

I have the following structure:
 brief description
 code

I need to create a view with the top 5 'nombre_institucion' from the first table with most 'delitos' (entries in antecedente_delito).
Basically the result I need in the view is:


Nombre_institucionnumero_delitos
inst132
inst230
inst325
inst418
inst510



A little MySQL help - FenixR - 2012-11-19

Screw this im writing in spanish:

No puedo recordar los codigos ahorita, pero se que necesitas relacionar la tabla que tiene los nombres de las instituciones con la tabla que tiene los delitos, despues tienes que hacerle un "order by" descendente (Creo que es ese el que va de menor a mayor), despues tienes que hacer una condicion para que te de los primeros 5 resultados de ese order by para mostrarlos.


A little MySQL help - Manu - 2012-11-19

The descending order and limit are easy, I'm stuck on how to relate both tables, since I have to go through like 3 in between.


A little MySQL help - FenixR - 2012-11-19

Manu Wrote:The descending order and limit are easy, I'm stuck on how to relate both tables, since I have to go through like 3 in between.

Tenes que traertelas contigo, porque sino, no relacionara los datos y no te traera nada. Lo que si no me acuerdo es como ocultar los campos que no quieres mostrar.

Si tuviera access en esta maquina te haria la relacion facilmente desde las tablas graficas que tiene.