6. UsingphyMyAdmintocreate SQL querieswithArchivistToolkit
6
Browse
Selectthe Browse tab.Clicka table name onthe listof tables,e.g.,Accessions.
Letsyou browse recordsina table.
The Appendix of thisdocumentlistssome same datafromimportanttablesinthe system.The sample
data showsthe “id” fieldsthatyouneedtoknow inorderto create SQL statementsthatgetfieldsfrom
more than one table.
7. UsingphyMyAdmintocreate SQL querieswithArchivistToolkit
7
SQL – one table selected
Selectthe SQLtab
A defaultquerywilldisplayforthe chosentable.Select*meansselectall fieldsinthe table.
We will onlybe usingthe SELECTcommand. Notice a listof fieldsor‘columns’forthe chosentable is
shownonthe right-handside of the screen.
8. UsingphyMyAdmintocreate SQL querieswithArchivistToolkit
8
SQL multiple table query
The general syntax of an SQL query isto identifythe fieldsyouwantinthe “select” clause,thenlistthe
tablesinthe “from” clause. Inthe “where” clause youidentifywhichidfieldsare commonbetweenthe
tables,andoptionallyanyconditions.The optional “orderby” clause may be usedtospecifysorting
preference.
Example:Copyandpaste thissample queryintothe querybox:
SELECT
Resources.resourceId,
Resources.resourceIdentifier1,
Resources.title asResourceTitle,
ResourcesComponents.title asComponentTitle,
ResourcesComponents.resourceLevel,
ResourcesComponents.resourceComponentIdasComponentIdentifier,
ResourcesComponents.restrictionsApply,
ArchDescriptionRepeatingData.title asNoteType,
ArchDescriptionRepeatingData.notesEtcTypeId,
ArchDescriptionRepeatingData.noteContent
FROM
`Resources`,`ResourcesComponents`,`ArchDescriptionRepeatingData`
WHERE
Resources.resourceId=ResourcesComponents.resourceIdAND
ResourcesComponents.resourceId=ArchDescriptionRepeatingData.resourceIdAND
ArchDescriptionRepeatingData.notesEtcTypeIdIN ('8','9','31')
ORDER BY
Resources.resourceId,ComponentTitle;
Thenclickthe GO button
9. UsingphyMyAdmintocreate SQL querieswithArchivistToolkit
9
Resultsof query.Thisqueryreturnedover72 thousandrows!Itshows30 rows at a time,andyou can
scroll horizontallytosee the contentsof the fields.
Click‘Showquery box’to editthe query
Try this: Editthe WHERE clause,adding aconditiontolistonlyMS0253:
WHERE
Resources.resourceId=ResourcesComponents.resourceIdAND
ResourcesComponents.resourceId=ArchDescriptionRepeatingData.resourceIdAND
ArchDescriptionRepeatingData.notesEtcTypeIdIN ('8','9','31') AND
Resources.resourceidentifier1='MS0253'
ThenclickGO button
10. UsingphyMyAdmintocreate SQL querieswithArchivistToolkit
10
Resultsof revisedquery,42rowsselected.
Exercise toretrieve extentsinDCAAP
1. Findinformationabout repositories,includingthe importantrepositoryId
a. Selectthe SQLtab
i. Enter thisqueryandclickGo
select* from`Repositories`;
ii. Note the DCAAPrepositoryidis5. Let’sfindthe extentsof Resourcesassociated
withDCAAP:
b. Selectthe SQLtab
i. Enter thisqueryandclickGo
(note the fieldnamesare enclosedinbackticksinthe selectclause,but
the fieldname inthe where clause isnot.The value inthe where clause
isenclosedinsingle quotes;the statementendsinasemicolon.)
select`title`,`extentNumber`,`extentType`
from`Resources`
where
Resources.repositoryId='5';
13. UsingphyMyAdmintocreate SQL querieswithArchivistToolkit
13
Selectthe Export option.
The followingoptionselector displays(the defaultFormatmaysay SQL):
Choose Quickor Customdisplayoptions.
Choose a Format,e.g.,CSV forExcel
Clickthe Go button
The file will be downloadedtoyourworkstation,asinthisexample,Resources.csv
17. UsingphyMyAdmintocreate SQL querieswithArchivistToolkit
17
Appendix
Sample data
Table: Repositories
repositoryId: 1
repositoryName: Special CollectionsResearchCenter,The George WashingtonUniversity
shortName: Spec
repositoryId: 2
repositoryName: Global ResourcesCenter
shortName: GRC
repositoryId: 3
repositoryName: Giftsand Exchange
shortName: Gifts
repositoryId: 4
repositoryName: SC Office
shortName: SCO
repositoryId: 5
repositoryName: DC AfricanaArchivesProject
shortName: DCAAP
Table: Resources
Sample Record
repositoryId: 1
resourceId: 6
created: 2014-02-20 13:10:5037
title: Samuel Solomonpapers
dateExpression: 1932-1964
dateBegin: null
dateEnd: null
extentNumber: 36
extentType: linearfeet
displayCreator: Solomon,Samuel Joseph
displayRepository: Special CollectionsResearchCenter,The George WashingtonUniversity
resourceIdentifier1: MS2092
resourceIdentifier2: null
findingAidTitle: Guide to the Samuel Solomonpapers,
<date calendar="gregorian"era="ce">1932-1964</date>
findingAidDate: 2006
author: Processedby:Special CollectionsStaff;machine-readable findingaidcreatedby:
JenniferKing
descriptionRules: DescribingArchives:A ContentStandard
18. UsingphyMyAdmintocreate SQL querieswithArchivistToolkit
18
Table: ResourcesComponents
Sample Record
resourceId: 6
resourceComponentId: 2667
sequenceNumber: 0
title: Papers,
dateExpression: 1932-1964
resourceLevel: series
subdivisionIdentifier: MS2092 Series1
Table: ArchDescriptionRepeatingData
Sample Record
resourceComponentId: 2667
repeatingDataType: Note
sequenceNumber: 1
notesEtcTypeId: 31
title: Scope and Contentsnote
noteContent: Thisseriesconsistsof documentsfrom Samuel Solomon's career in aviation. He
was manager of the Washington National Airport; organized a new airline,
National Airways(the predecessorof NortheastAirlines) with Amelia Earhart in
1933; was presidentandtrainerof the War TrainingInstitute; andwasChairman
of the Airlines Committee for the United States Air Policy.
The materialsrange indate from 1932-64.
Table: NotesEtcTypes
Sample Record
notesEtcTypeId: 31
notesEtcName: Scope and Contentsnote
Sample Record
notesEtcTypeId: 8
notesEtcName: ConditionsGoverningAccessnote