MySQL Forums
Forum List  »  Spanish

Ayuda con Consulta MySQL
Posted by: Slashhh Pérez Reverte
Date: May 26, 2009 05:30PM

Buenas Noches.

Necesito ayuda con una consulta MultiTabla (3 tablas), con la funcion Max() incluída.
Os explico:

Tengo una tabla que es "Montañas" con los campos id_montaña, altitud y otros.
Tengo otra tabla que es "Relacion_montaña_pais" con los campos id_relacion, id_montaña, id_pais.
Tengo otra tabla que se "paises" con los campos id_pais, nombre y otros.

Lo que necesito es encontrar la montaña más alta de cada país.
Hay que darse cuenta que las tablas tienen una relación "N a N", ya que una montaña puede tener varios paises, y un pais puede tener varias montañas.

La consulta que tengo, y no funciona, es esta:
SELECT MAX( cimas.altitud ), cimas.*, paises.continente AS continente, paises.nombre AS pais_n, paises.ISO_xxx AS pais_c
FROM cimas, paises, relacion_pais_cima
WHERE cimas.id_cima=relacion_pais_cima.id_cima AND relacion_pais_cima.id_pais=paises.id_pais
AND cimas.id_cima IS NOT NULL
GROUP BY pais_n
ORDER BY continente DESC , pais_n DESC

¿Se puede hacer en una sola consulta? ¿En una multiconsulta? ¿O tiene que haber varias consultas?

Muchas Gracias...



Edited 1 time(s). Last edit at 05/26/2009 05:37PM by Slashhh Pérez Reverte.

Options: ReplyQuote


Subject
Views
Written By
Posted
47525
July 11, 2006 07:51AM
3766
February 25, 2010 05:22PM
3124
November 09, 2010 06:58AM
5167
June 07, 2010 03:05PM
3404
August 31, 2011 05:59AM
7385
August 30, 2006 09:33AM
8045
November 14, 2007 03:15AM
4292
June 13, 2011 08:59AM
11597
February 12, 2008 06:04PM
7449
March 11, 2008 05:17AM
4050
April 10, 2010 06:07PM
8266
August 25, 2008 07:22PM
8648
March 23, 2008 09:27AM
5328
April 19, 2008 05:08PM
4828
May 11, 2008 12:28PM
7241
March 28, 2008 10:20AM
6387
June 05, 2008 08:21AM
4809
May 20, 2009 06:30PM
7367
April 18, 2008 12:52PM
4486
May 20, 2009 06:27PM
5290
April 30, 2008 02:21PM
5066
June 05, 2008 08:02AM
6958
May 02, 2008 01:15PM
5077
May 08, 2008 08:13PM
5174
May 08, 2008 09:05AM
7430
June 04, 2008 01:47PM
4743
May 29, 2008 04:34AM
4791
May 29, 2008 05:54AM
5059
June 02, 2008 11:47AM
9869
June 04, 2008 02:01PM
5832
June 05, 2008 07:46AM
6428
June 09, 2008 02:31AM
4540
June 09, 2008 09:53AM
4922
June 11, 2008 10:47AM
5390
June 16, 2008 06:28AM
7466
September 03, 2008 04:34PM
9339
September 05, 2008 04:09AM
5191
December 14, 2008 11:49AM
7407
May 19, 2009 08:31AM
4710
May 19, 2009 08:43AM
Ayuda con Consulta MySQL
5578
May 26, 2009 05:30PM
3971
July 29, 2009 08:59AM
3933
August 02, 2009 09:19PM
4702
August 02, 2009 03:18PM
4401
August 28, 2009 06:55PM
7640
August 31, 2009 03:02PM
4634
September 14, 2009 01:54PM
4705
September 24, 2009 09:43PM
3885
September 25, 2009 09:30AM
4162
October 07, 2009 01:51AM
5459
November 05, 2009 05:09PM
4088
November 25, 2009 06:51AM
3261
November 26, 2009 04:13AM
3768
December 28, 2009 10:31PM
4301
February 02, 2010 09:55AM
8923
February 12, 2010 08:35AM
4185
March 01, 2010 03:08PM
3438
March 03, 2010 08:23AM
5240
March 05, 2010 07:57AM
2983
March 06, 2010 04:37PM
4623
April 13, 2010 03:43PM
3192
August 08, 2010 03:15PM
2677
August 08, 2010 03:54PM
2042
September 15, 2010 10:06AM
9570
September 18, 2010 10:24AM
2205
October 10, 2010 10:05AM
1969
November 13, 2010 05:53AM
2138
October 18, 2010 04:05PM
1973
October 18, 2010 07:34PM
1997
January 20, 2011 03:13PM
3011
February 14, 2011 09:18AM
2822
January 31, 2011 04:19PM
2877
February 02, 2011 11:41AM
1837
March 17, 2011 01:35PM
2090
July 30, 2011 10:51PM
1470
August 15, 2011 03:50PM
2346
September 20, 2011 10:54AM
1314
September 20, 2011 01:53PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.