Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3785d8e

Browse files
doc: Make UPDATE FROM examples consistent
The original first half of the example used an employees table and anaccounts.sales_person foreign key column, while the second half (addedin commit8f889b1) used a salesmen table and accounts.sales_idfor the foreign key. This makes everything use the original names.Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>Discussion:https://postgr.es/m/87o81vqjw0.fsf@wibble.ilmari.org
1 parentebc8b7d commit3785d8e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎doc/src/sgml/ref/update.sgml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,23 +387,23 @@ UPDATE employees SET sales_count = sales_count + 1 WHERE id =
387387

388388
<para>
389389
Update contact names in an accounts table to match the currently assigned
390-
salesmen:
390+
salespeople:
391391
<programlisting>
392392
UPDATE accounts SET (contact_first_name, contact_last_name) =
393-
(SELECT first_name, last_name FROMsalesmen
394-
WHEREsalesmen.id = accounts.sales_id);
393+
(SELECT first_name, last_name FROMemployees
394+
WHEREemployees.id = accounts.sales_person);
395395
</programlisting>
396396
A similar result could be accomplished with a join:
397397
<programlisting>
398398
UPDATE accounts SET contact_first_name = first_name,
399399
contact_last_name = last_name
400-
FROMsalesmen WHEREsalesmen.id = accounts.sales_id;
400+
FROMemployees WHEREemployees.id = accounts.sales_person;
401401
</programlisting>
402402
However, the second query may give unexpected results
403-
if <structname>salesmen</structname>.<structfield>id</structfield> is not a unique key, whereas
403+
if <structname>employees</structname>.<structfield>id</structfield> is not a unique key, whereas
404404
the first query is guaranteed to raise an error if there are multiple
405405
<structfield>id</structfield> matches. Also, if there is no match for a particular
406-
<structname>accounts</structname>.<structfield>sales_id</structfield> entry, the first query
406+
<structname>accounts</structname>.<structfield>sales_person</structfield> entry, the first query
407407
will set the corresponding name fields to NULL, whereas the second query
408408
will not update that row at all.
409409
</para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp