Nicole Engard schreef op di 15-10-2013 om 12:20 [-0500]:
Anyone know if there is a way to query a marc field based on the indicator value.
I have this report (which works):
select b.title, b.author, ExtractValue(m.marcxml,'//datafield[@tag="521"]/subfield[@code>="a"]') AS lexile from biblio b left join biblioitems m using (biblionumber) where ExtractValue(m.marcxml,'//datafield[@tag="521"]/subfield[@code>="a"]') between <<Lexile between>> and <<and>>
But I want to only query 521s that have a 8# in the indicators. My report will find all of the below:
The language that ExtractValue uses is called 'xpath', and it's a way of describing paths into XML. You should make your datafield request qualified with the extra things you need. For example, a MARCXML field looks like: <datafield tag="100" ind1="1" ind2=" "> <subfield code="a">Gravelle, Karen.</subfield> </datafield> so the attributes you care about are 'tag' (which you already have), ind1, and ind2. Xpath lets you and/or things together, so you could use something like: //datafield[@tag="521" and @ind1="8" and @ind2=" "]/subfield... More reference here: http://www.w3schools.com/xpath/default.asp but I checked the syntax of this particular answer here: http://stackoverflow.com/questions/6029232/xpath-select-multiple-attr mostly because I knew what to search for :) I haven't tested this solution, btw, but it should work. -- Robin Sheat Catalyst IT Ltd. ✆ +64 4 803 2204 GPG: 5FA7 4B49 1E4D CAA4 4C38 8505 77F5 B724 F871 3BDF