From 0aaac043442c255a7f697338a6cfbccdc4540138 Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:20:46 +0400 Subject: [PATCH] Fixed Only Group By problem (#4073) Signed-off-by: objecttothis --- .../Migrations/20210422000001_remove_duplicate_links.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Database/Migrations/20210422000001_remove_duplicate_links.php b/app/Database/Migrations/20210422000001_remove_duplicate_links.php index 90a45ac84..10effca2b 100644 --- a/app/Database/Migrations/20210422000001_remove_duplicate_links.php +++ b/app/Database/Migrations/20210422000001_remove_duplicate_links.php @@ -32,14 +32,13 @@ class Migration_remove_duplicate_links extends Migration $this->db->transStart(); $builder = $this->db->table('attribute_links'); + $builder->select('item_id, definition_id, attribute_id, COUNT(*) as count'); $builder->where('sale_id', null); $builder->where('receiving_id', null); $builder->groupBy('item_id'); $builder->groupBy('definition_id'); $builder->groupBy('attribute_id'); - $builder->having('COUNT(item_id) > 1'); - $builder->having('COUNT(definition_id) > 1'); - $builder->having('COUNT(attribute_id) > 1'); + $builder->having('count > 1'); $duplicated_links = $builder->get(); $builder = $this->db->table('attribute_links');