Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
cd5d464e
Commit
cd5d464e
authored
Jan 19, 2006
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doc patch that adds an example of a correllated UPDATE.
David Fetter
parent
807cb000
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
doc/src/sgml/ref/update.sgml
doc/src/sgml/ref/update.sgml
+19
-1
No files found.
doc/src/sgml/ref/update.sgml
View file @
cd5d464e
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/update.sgml,v 1.3
3 2005/10/12 23:19:22 tgl
Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/update.sgml,v 1.3
4 2006/01/19 23:09:42 momjian
Exp $
PostgreSQL documentation
-->
...
...
@@ -205,14 +205,32 @@ UPDATE employees SET sales_count = sales_count + 1 FROM accounts
WHERE accounts.name = 'Acme Corporation'
AND employees.id = accounts.sales_person;
</programlisting>
</para>
<para>
Perform the same operation, using a sub-select in the
<literal>WHERE</literal> clause:
<programlisting>
UPDATE employees SET sales_count = sales_count + 1 WHERE id =
(SELECT sales_person FROM accounts WHERE name = 'Acme Corporation');
</programlisting>
</para>
<para>
Now that all the papers are signed, update the most recently closed
deal of the travelling salesperson who closed the Rocket Powered
Skates deal with the Acme Corporation.
<programlisting>
UPDATE employees SET last_closed_deal = deal.id
FROM accounts JOIN deals ON (account.id = deal.account_id)
WHERE deal.employee_id = employees.id
AND deal.name = 'Rocket Powered Skates'
AND accounts.name = 'Acme Corporation'
ORDER BY deal.signed_date DESC LIMIT 1;
</programlisting>
</para>
<para>
Attempt to insert a new stock item along with the quantity of stock. If
the item already exists, instead update the stock count of the existing
item. To do this without failing the entire transaction, use savepoints.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment