Skip to content

Instantly share code, notes, and snippets.

@jeff jeff/update.sql Secret
Last active Aug 29, 2015

Embed
What would you like to do?
-- 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
You can’t perform that action at this time.