<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - JOIN tablicy różnej długości z kolumną innej tabeli]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=2243&amp;type=atom"/>
	<updated>2014-12-09T21:02:15Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=2243</id>
		<entry>
			<title type="html"><![CDATA[Odp: JOIN tablicy różnej długości z kolumną innej tabeli]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=5390#p5390"/>
			<content type="html"><![CDATA[zerknij na to

with tabela_1 (id1,tabela_2_id) as (values (1,array[1,2,3]),(2,array[1,3]),(3,array[2]),(4,null),(5,array[2,3,4]))
,tabela_2 (id2,namee) as (values (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'))
select * 
from tabela_1 t1
join tabela_2 t2 on array[t2.id2] <@ t1.tabela_2_id]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2014-12-09T21:02:15Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=5390#p5390</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[JOIN tablicy różnej długości z kolumną innej tabeli]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=5389#p5389"/>
			<content type="html"><![CDATA[Witam wszystkich forumowiczów!

Mam mały problem ze złączeniami, a więc tak :

Mam tabela_1

id1 | tabela_2_id typu integer[]
-- |---------------------------------
 1 | {1,2,3}
 2 | {1,3}
 3 | {2}
 4 | 
 5 | {2,3,4}

oraz tabela_2

id2 |  name typu charcter varying(1)
-- |---------------------------------
 1 | a
 2 | b
 3 | c
 4 | d
 5 | e


i teraz chciałbym się połączyć tak aby każdy id2 z tabela_2_id był złączony z każdym elementem z tablic kolumny tabela_2_id

id2 |  name typu charcter varying(1)             | id1
--- |---------------------------------------|------
  1  | a                                                   | 1
  2  | b                                                   | 1 
  3  | c                                                   | 1
  1  | a                                                   | 2
  3  | c                                                   | 2
  2  | b                                                   | 3
  5  | e                                                   | 
  2  | b                                                   | 5 
  3  | c                                                   | 5
  4  | d                                                   | 5


Byłbym bardzo wdzięczny za jakiekolwiek podpowiedzi sugestię..]]></content>
			<author>
				<name><![CDATA[djsalat]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=2183</uri>
			</author>
			<updated>2014-12-09T14:38:39Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=5389#p5389</id>
		</entry>
</feed>
