[Koha] SQL query help

Melissa Haig melissa at floods.org
Wed Aug 10 05:47:12 NZST 2016


Hello all,

My SQL is very rusty, and I'm trying to write a query to find records where
there are multiple 650 fields with the same 650a subfield.

For example:
*650* *#0**$a*Real property*$z*Tippah County*$v*Maps.
*650* *#0**$a*Real property*$z*Mississippi*$v*Maps.

Here is the query I've written so far and the error I get. I will admit I'm
very rusty at SQL and if this is the wrong way to go about it I'm happy to
try a different tactic.

SELECT CONCAT('<a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber=
',biblionumber,'\">',biblionumber,'</a>')
AS bibnumber
FROM
(SELECT biblionumber,
ExtractValue(marcxml,'//datafield[@tag="650"]/subfield[@code>="a"]')
AS subjects
HAVING
COUNT(ExtractValue(marcxml,'//datafield[@tag="650"]/subfield[@code>="a"]) >
1

And the error:
*The following error was encountered:*
The database returned the following error:
called with 2 bind variables when 0 are needed
Please check the log for further details.

Thanks for any help!

Melissa Haig


Research Librarian

Association of State Floodplain Managers

575 D’Onofrio Drive, Suite 200 | Madison, WI  53719

tel:* 608-828- <608-828-3000>6342 * | melissa at floods.org


More information about the Koha mailing list