<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - Proszę o pomoc przy budowanie podzapytania]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=1486&amp;type=atom"/>
	<updated>2013-04-19T07:10:47Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=1486</id>
		<entry>
			<title type="html"><![CDATA[Odp: Proszę o pomoc przy budowanie podzapytania]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4154#p4154"/>
			<content type="html"><![CDATA[poniższy select pokazuje zasadę porównania po nakładających się figurach box, uwzględniając wyświetlenie użytkownika podselectem

with   users as (          select 1 as id,'u1' as name
                 union all select 2 as id,'u2' as name
                 union all select 3 as id,'u3' as name) 
     ,traces as (          select 1 as userid, box '((0,0),(1,1))' as inne_kolumny
                 union all select 2 as userid, box '((-5,-2),(0,0))' as inne_kolumny
                 union all select 2 as userid, box '((-5,-2),(-2,-1))' as inne_kolumny
                 union all select 3 as userid, box '((10,10),(12,11))' as inne_kolumny) 
    ,polygon as (          select box '((1,1),(2,2))' as inne_kolumny
                 union all select box '((-1,-1),(3,3))' as inne_kolumny
                 union all select box '((2,2),(3,3))' as inne_kolumny) 
select (select name from users where id=t.userid) as user_name, t.inne_kolumny as box_uzytkownika, p.inne_kolumny as box_majacy_czesc_wspolna
from traces t 
join polygon p on t.inne_kolumny && p.inne_kolumny]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2013-04-19T07:10:47Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4154#p4154</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Proszę o pomoc przy budowanie podzapytania]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4153#p4153"/>
			<content type="html"><![CDATA[Witam.

Mam dwie tabele:
USERS : ID, NAME
TRACERS: USERID,kolumny_daneGeoprzestrzenne
POLYGON: kolumny_daneGeoprzestrzenne

chciałbym teraz zrobić coś mniej więcej takiego

select user.name, tracer.inne_kolumny
from users as user, traces as tracer, polygon as poly
where tracer.kolumny_daneGeoprzestrzenne zawieraja sie w poly.kolumny_daneGeoprzestrzenne AND user.ID = tracer.USERID


próbowałem wrzucać podzapytanie bezpośrednio do wybieranej kolumny z selecta cos jak:



select  tracer.inne_kolumny, (select user.name from users as user, tracers as tracer where user.ID = tracer.USERID)
from users as user, traces as tracer, polygon as poly
where tracer.kolumny_daneGeoprzestrzenne zawieraja sie w poly.kolumny_daneGeoprzestrzenne


ale to nie działa :)

Ogólnie chodzi mi o takie rozwiązanie: IDEK usera z tabeli TRACERS chciałbym zamienić na NAME usera z kolumny USERS

Z góry dziękuję za pomoc]]></content>
			<author>
				<name><![CDATA[Hilar]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1568</uri>
			</author>
			<updated>2013-04-18T15:32:46Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4153#p4153</id>
		</entry>
</feed>
