<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - UPDATE dwoch tabel - co robie nie tak:)]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=1485&amp;type=atom"/>
	<updated>2013-04-12T13:39:52Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=1485</id>
		<entry>
			<title type="html"><![CDATA[Odp: UPDATE dwoch tabel - co robie nie tak:)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4152#p4152"/>
			<content type="html"><![CDATA[oba rozwiazania zadzialaly
dziekuje]]></content>
			<author>
				<name><![CDATA[KotonPL]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1529</uri>
			</author>
			<updated>2013-04-12T13:39:52Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4152#p4152</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: UPDATE dwoch tabel - co robie nie tak:)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4151#p4151"/>
			<content type="html"><![CDATA[update tabela1 as t1
set do_uzupelnienia = t2.uzupelniajace
from tabela2 as t2
where t2.id_wiersza = t1.id_wiersza
and t1.do_uzupelniania is null;]]></content>
			<author>
				<name><![CDATA[depesz]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1564</uri>
			</author>
			<updated>2013-04-12T13:05:42Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4151#p4151</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: UPDATE dwoch tabel - co robie nie tak:)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4150#p4150"/>
			<content type="html"><![CDATA[Proponuje tak
update tabela1 set do_uzupelnienia = (select uzupelniajace from tabela2 where tabela1.id_wiersza = tabela2.id_wiersza) WHERE tabela1.do_uzupelnienia is null;

Jeśli po update pole tabela1.do_uzupelnienia będzie miało wartość null tzn, że nie masz w tabeli2 wartośći w polu uzupelniajace lub nie ma takiego id_wiersza]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2013-04-12T12:38:51Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4150#p4150</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[UPDATE dwoch tabel - co robie nie tak:)]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4149#p4149"/>
			<content type="html"><![CDATA[kolumny w pierwszej tabeli to id_wiersza, do_uzupelnienia
kolumny w drugiej tabeli to id_wiersza2, uzupelniajace

update tabela1 set do_uzupelnienia = (select uzupelniajace
from tabela2
where
tabela1.id_wiersza = tabela2.id_wiersza
and
tabela1 is null);

pierwsza tabele mam juz czesciowo uzupelniona i chcialbym reszte pustych pol uzupelnic danymi z drugiej tabeli, ale po wykonaniu tej instrukcji tabela1 uzupelnia sie danymi z tabeli drugiej, ale tworza sie puste pola tam gdzie bylo juz uzupelnione pierwotnie - co robie nie tak?:)]]></content>
			<author>
				<name><![CDATA[KotonPL]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1529</uri>
			</author>
			<updated>2013-04-12T09:55:21Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4149#p4149</id>
		</entry>
</feed>
