diff --git a/plugins/mariadbplugin/CollectionFunctions.go b/plugins/mariadbplugin/CollectionFunctions.go index 84c3602..c87b7d5 100644 --- a/plugins/mariadbplugin/CollectionFunctions.go +++ b/plugins/mariadbplugin/CollectionFunctions.go @@ -80,10 +80,10 @@ func (DBConnection *MariaDBPlugin) GetCollections(PageStart uint64, PageStride u ) Counts ON Counts.CollectionID = CL.ID -- This part gets a preview image location LEFT JOIN ( - SELECT Location, CollectionMembers.CollectionID as CollectionID, MIN(CollectionMembers.OrderWeight) - FROM Images - INNER JOIN CollectionMembers ON CollectionMembers.ImageID = Images.ID - GROUP BY CollectionMembers.CollectionID + SELECT CM.CollectionID as CollectionID, Images.Location as Location + FROM CollectionMembers as CM + INNER JOIN Images on Images.ID = CM.ImageID + WHERE OrderWeight = (SELECT MIN(OrderWeight) From CollectionMembers WHERE CollectionMembers.CollectionID = CM.CollectionID) ) Preview ON Preview.CollectionID = CL.ID ORDER BY Name LIMIT ? OFFSET ?;` diff --git a/plugins/mariadbplugin/CollectionSearch.go b/plugins/mariadbplugin/CollectionSearch.go index 46b375c..165eb99 100644 --- a/plugins/mariadbplugin/CollectionSearch.go +++ b/plugins/mariadbplugin/CollectionSearch.go @@ -92,10 +92,10 @@ func (DBConnection *MariaDBPlugin) SearchCollections(Tags []interfaces.TagInform GROUP BY CollectionID ) Counts ON Counts.CollectionID = ID LEFT JOIN ( - SELECT Location, CollectionMembers.CollectionID as CollectionID, MIN(CollectionMembers.OrderWeight) - FROM Images - INNER JOIN CollectionMembers ON CollectionMembers.ImageID = Images.ID - GROUP BY CollectionMembers.CollectionID + SELECT CM.CollectionID as CollectionID, Images.Location as Location + FROM CollectionMembers as CM + INNER JOIN Images on Images.ID = CM.ImageID + WHERE OrderWeight = (SELECT MIN(OrderWeight) From CollectionMembers WHERE CollectionMembers.CollectionID = CM.CollectionID) ) Preview ON Preview.CollectionID = ID ` if len(IncludeTags) > 0 {