Quick Query — Finding Locations where Nothing is Assigned in Archivists’ Toolki

I just wrote a quick query to give records in the locations table in Archivists’ Toolkit that don’t have instances assigned to them. This sounds like a pretty common thing that folks want to see — here it is:

SELECT
*
FROM
LocationsTable loc
WHERE
loc.locationId BETWEEN 0 AND 10000
AND loc.locationId NOT IN (SELECT
locationId
FROM
ArchDescriptionInstances containers
WHERE
containers.locationId BETWEEN 0 AND 10000)
AND loc.locationId NOT IN (SELECT
locationId
FROM
AccessionsLocations accession
WHERE
accession.locationId BETWEEN 0 AND 10000);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s