The two most common SQL statements within Koha application reports
This document will outline the two most common statements which appear in SQL reports run in the Koha application. SQL reports within the Koha application can only be run the return information that exists in the database, however, other SQL tools may allow the editing and updating of the underlying database. Editing and updating the underlying database is not possible from within the Koha reports tool.
The two statements required to structure an SQL report in Koha
SELECT
FROM
These two statements that will appear in almost every SQL report created on Koha. After the SELECT statement, there will be a list of the fields the report should display. After the FROM statement, there will be a list of the tables the information should be taken from.
SELECT
One of two mandatory statements that enable a report to work. This function defines the columns you want to draw information from. It should appear at the start of every report.
FROM
One of two mandatory functions to enable the report to work. FROM is the function that determines what the primary table the information requested with the SELECT function will be drawn from.
Example of how these statements are used in a report
SELECT borrowers.cardnumber, borrowers.firstname, borrowers.surname
FROM borrowers
| Version | Date | Detail | Author |
| 1.0 | 28/04/26 | Document created | Holly Cooper |
| 1.2 | 29/04/26 | Details added | Holly Cooper |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|