[Qgis-user] save a join between attribute and table in gpkg?
John Stevenson - BGS
jostev at bgs.ac.uk
Fri Oct 17 12:19:47 PDT 2025
We have also had success with views. There are a few queries to run to register them correctly. You can do this via the QGIS Database manager. DB Browser for SQLite is also good. Note that the view must include an integer ID to render correctly in some settings.
CREATE VIEW IF NOT EXISTS "view_locality_geology" AS
SELECT
loc.fid as fid,
loc.name as name,
loc.rock_type,
geo.minerals as colour,
geo.age as age,
loc.geometry as geometry
FROM locality as loc
LEFT JOIN geological_units geo on geo.rock_type= rock_type;
INSERT INTO gpkg_contents
VALUES('view_locality_geology,'features','view_locality_geology','View with geology information at locality positions','2023-09-15T13:21:52.679Z',NULL,NULL,NULL,NULL,4326);
INSERT INTO gpkg_geometry_columns
VALUES('view_locality_geometry','geometry','POINT',4326,1,0);
From: QGIS-User <qgis-user-bounces at lists.osgeo.org> On Behalf Of Mike Bundock via QGIS-User
Sent: 17 October 2025 20:28
To: Simon Dietmann <dietmann at pgnu.de>
Cc: qgis-user <qgis-user at lists.osgeo.org>
Subject: Re: [Qgis-user] save a join between attribute and table in gpkg?
hi
we had a similar issue in that we could not find a way of saving join information. The technique we ended up using was to extend the qml syntax to support join field definitions, and use a small function to re-establish joins correctly. This is really useful if the same sets of tables are used in multiple projects. Its simply a matter of loading the qml files using the layer -> properties -> load style function.
We also use it as an easy method to define the join fields within other applications such as Augview. It means that UI behaviour within multiple applications is consistent and only needs defining once.
hope that is helpful. If you want to use the same syntax, let me know & i will send some documentation.
regards
Mike Bundock | CEO
Augview | P O Box 125046, St Heliers, Auckland 1740, New Zealand
p: +64 9 575 5298 | m: +64 27 575 5298 | e: mailto:mike.bundock at augview.net| w: www.augview.net<http://www.augview.net>
[Image removed by sender.] [Image removed by sender.] [Image removed by sender.]
Winner of Innovation & Commercialisation and Supreme Awards at 2014 NZ Spatial Excellence Awards
Winner of Innovation & Commercialisation Award at 2014 Asia Pacific Spatial Excellence Awards
On Fri, 17 Oct 2025, 11:13 pm Simon Dietmann via QGIS-User, <qgis-user at lists.osgeo.org<mailto:qgis-user at lists.osgeo.org>> wrote:
Dear list,
I am trying to export some feature classes inside a common gpkg that have attribute joins to a table that’s also stored in the same gpkg. Afaics there is no possibility to store the information about the table join also inside the gpkg, is that correct?
Is there a way to store (and share) the joins except sharing a .qgz file?
Thanks for your advice,
Regards
Simon
i.A. Simon Dietmann
Projektleiter | Geograph
[cid:image001.png at 01DC3FAB.C25EC320]
PGNU Planungsgesellschaft Natur & Umwelt mbH
Amtsgericht Frankfurt am Main, HRB 111938;
Geschäftsführer: Dr. Benjamin Hill, Dorit Thurm, Sebastian Braun
Hamburger Allee 45 +++ 60486 Frankfurt am Main<https://www.google.com/maps/search/Hamburger+Allee+45+%2B%2B%2B+60486+Frankfurt+am+Main?entry=gmail&source=g>
Durchwahl: +49 69 952964-32 +++ Fax: +49 69 952964-99
E-Mail: dietmann at pgnu.de<mailto:dietmann at pgnu.de> +++ Web: www.pgnu.de<http://www.pgnu.de>
> Diese E-Mail könnte vertrauliche und/oder rechtlich geschützte Informationen enthalten. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.
> This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________
QGIS-User mailing list
QGIS-User at lists.osgeo.org<mailto:QGIS-User at lists.osgeo.org>
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
This email and any attachments are intended solely for the use of the named recipients. If you are not the intended recipient you must not use, disclose, copy or distribute this email or any of its attachments and should notify the sender immediately and delete this email from your system. UK Research and Innovation (UKRI) has taken every reasonable precaution to minimise risk of this email or any attachments containing viruses or malware but the recipient should carry out its own virus and malware checks before opening the attachments. UKRI does not accept any liability for any losses or damages which the recipient may sustain due to presence of any viruses.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20251017/f068f0f7/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ~WRD0000.jpg
Type: image/jpeg
Size: 823 bytes
Desc: ~WRD0000.jpg
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20251017/f068f0f7/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 8911 bytes
Desc: image001.png
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20251017/f068f0f7/attachment.png>
More information about the QGIS-User
mailing list