Re: including the result of one query in another query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, June 26, 2005 4:53 am, Brian V Bonini said:
> On Sun, 2005-06-26 at 06:38, Pedro Quaresma de Almeida wrote:
>> 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');
>
>
> I believer DISTINCT is not an SQL function, it's a statement.
>
> SELECT DISTINCT column_name FROM table_name;

In some implementations:
distinct(expr[, expr]*) [,expr]*
can be used to get only the columns within () to be distinct.
Other columns outside the parens can be duplicates.

I forget if MySQL does this or PostgreSQL.
http://mysql.com
http://postgresql.org

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux