Skip to content

Instantly share code, notes, and snippets.

@jeff

jeff/update.sql Secret

Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeff/50f2999095e175c49362 to your computer and use it in GitHub Desktop.
Save jeff/50f2999095e175c49362 to your computer and use it in GitHub Desktop.
-- Show copies that we would like to update from location 3819 to location 4870
SELECT acp.id, acn.label, acp.location AS current_location, 4870 AS new_location
FROM asset.copy AS acp
JOIN asset.call_number AS acn ON acp.call_number = acn.id
WHERE acp.circ_lib = 108
AND acp.location = 3819
AND UPPER(acn.label) LIKE 'YA FAN%'
AND NOT acp.deleted
AND NOT acn.deleted;
-- Actually perform the update
BEGIN;
UPDATE asset.copy AS acp
SET location = 4870
FROM asset.call_number AS acn
WHERE acp.call_number = acn.id
AND acp.circ_lib = 108
AND acp.location = 3819
AND UPPER(acn.label) LIKE 'YA FAN%'
AND NOT acp.deleted
AND NOT acn.deleted;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment