I’m building a small thing that I want to produce nicely formatted (for printing) reports. There is one aspect I’m stuck on.
I have a many-to-many relationship, with a join table. As an example, books to authors.
My goal is have a field in the report that looks like:
Title of book
by John Doe, Bill Smith, Tom Jones
(aside: extra nice if I can have John Doe, Bill Smith, and Tom Jones, but not essential.)
My tables are:
book:
- id
- title
author:
- id
- name
rel_book_author:
- book_id
- author_id
Ideally, in SQL with a query I’d be able to produce a table that is:
book_details
- title
- authors (which looks like “John Doe, Bill Smith, Tom Jones”, sourced from the
author
table.)
I attempted to use GROUP_CONCAT
but hsqldb is too old. I can’t see any other way of doing this at the query/SQL level (though would love suggestions.)
So perhaps I can do it at the report level. Here I’m a bit stuck, I can see how I might do something like:
Title of Book
* John Doe
* Bill Smith
* Tom Jones
or similar, by doing a join in the query that gives me repeated rows for each author and then grouping by title (or ID or whatever), but not how to format it properly.
I am using the inbuilt database on LibreOffice Base 7.4. This DB choice is something of a constraint as I’m building this for someone else, and just want to be able to hand them a file that works and not have to set up anything else. On the other hand if someone can recommend an option that is very easy to set up on a Windows laptop, that might also work.
Any help? Thanks in advance.