[Koha-bugs] [Bug 24741] Recent creation of unique index on library_groups erroneously removes rows

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Feb 28 10:51:32 CET 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24741

David Gustafsson <glasklas at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |glasklas at gmail.com

--- Comment #1 from David Gustafsson <glasklas at gmail.com> ---
I'm not 100%, but think a correct query to remove duplicates could be written
like:

DELETE FROM library_groups
WHERE id NOT IN (
  SELECT MIN(id)
  FROM ( SELECT * FROM library_groups ) AS lg
  GROUP BY parent_id, branchcode
)
AND NOT(parent_id IS NULL OR branchcode IS NULL);

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list