2012/6/26, Pedro Costa <[email protected]>:
> Obrigado pessoal..
>
> Já entendi...
>
> fiz isto:
>
> select rota2.the_geom, rota2.id from
> (SELECT id, the_geom
> FROM arcos
> JOIN
> (SELECT * FROM shortest_path('
> SELECT id2 as id,
> source::int4 AS source,
> target::int4 AS target,
> length*estado_actual.custo AS cost
> FROM arcos, estado_actual
> where arcos.estado_a = estado_actual.id_ea',
> 438,489,false,false))
> AS rota
> ON
> arcos.id2 = rota.edge_id) AS rota2
> using unique id
>
>
>
>
>
>
> Sem o using funciona mas com o using obtenho o seguinte erro:
>
> ERROR: syntax error at or near "using"
> LINE 27: using unique id
>
>
>
>
>
> Em 26-06-2012 17:50, Jean Domingues escreveu:
>> coloque a sua subquery entre parenteses, e coloque um alias, assim:
>> select sub.campo from (select campo from tabela) as sub;
>>
>> *De:* Pedro Costa <[email protected]>
>> *Para:* Comunidade PostgreSQL Brasileira
>> <[email protected]>
>> *Enviadas:* Terça-feira, 26 de Junho de 2012 13:12
>> *Assunto:* [pgbr-geral] query erro alias
>>
>> Olá pessoal,
>>
>> Estou a tentar fazer uma query como esta:
>>
>>
>> select the_geom from
>>
>> (SELECT the_geom
>> FROM arcos
>> JOIN
>> (
>> SELECT * FROM shortest_path('
>> SELECT id2 as id,
>> source::int4 AS source,
>> target::int4 AS target,
>> length*estado_actual.custo AS cost
>> FROM arcos, estado_actual
>> where arcos.estado_a = estado_actual.id_ea',
>> 438,489,false,false)) AS rota
>> ON
>> arcos.id2 = rota.edge_id)
>>
>> using unique id2
>>
>>
>> Mas devolve-me o seguinte erro:
>>
>> ERROR: subquery in FROM must have an alias
>> LINE 4: (SELECT the_geom
>>
>>
>> Será que podem ajudar a resolver?
>>
Creio que deva ser:
select rota2.the_geom, rota2.id from
(SELECT id, the_geom
FROM arcos
JOIN
(SELECT * FROM shortest_path('
SELECT id2 as id,
source::int4 AS source,
target::int4 AS target,
length*estado_actual.custo AS cost
FROM arcos, estado_actual
where arcos.estado_a = estado_actual.id_ea using unique id',
438,489,false,false))
AS rota
ON
arcos.id2 = rota.edge_id) AS rota2
;
Não entendi o unique na cláusula using.
Osvaldo
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral