You are here: including the result of one query in another query « PHP « IT news, forums, messages
including the result of one query in another query

Posted by Pedro Quaresma de Almeida on 06/26/05 13:38

Hi

I have two databases, on for aeromodelistas (aeromodelling) and
another for Códigos Postais (Postal Codes). I whant to do the
following query

SELECT CódigoPostal FROM Aeromodelistas
WHERE CódigoPostal IN
(SELECT distinct(CP4) FROM codigopostal.LOCART,codigopostal.DISTRITO
WHERE codigopostal.LOCART.DD=codigopostal.DISTRITO.DD
AND codigopostal.DISTRITO.DESIG='Coimbra');

This query is not working, and I do not know why. If I try the two
queries individualy they work, togheter they don't!?

But the question I want to put to the members of this list is the
following. Is it possible to do the following?

// first do the subquery
$sql_CP4s = "select distinct(CP4) from
codigopostal.LOCART,codigopostal.DISTRITO where
codigopostal.LOCART.DD=codigopostal.DISTRITO.DD and
codigopostal.DISTRITO.DESIG='$nomeDistrito'";

$resultado_CP4s = mysql_query($sql_CP4s,$ligacao);

$linha_CP4s = mysql_fetch_assoc($resultado_CP4s);

// then use it in the main query

$sql_Aero_Dist_Masc = "select count(Nome) from Aeromodelistas where
year(AnoQuota)=2005 and Sexo='Masculino' and Distrito IN $linha_CP4s";

How can we include the results (not just one) of one query in another
query?

Is it possible?

Thanks.

--
Pedro Henrique e Figueiredo Quaresma de Almeida

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация