From 9cbfc6c1db60dd88a3be5b4b4bfbae4f1c737bc9 Mon Sep 17 00:00:00 2001 From: duckietm Date: Fri, 27 Mar 2026 17:11:21 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=86=99=20Fix=20Groups=20Forum=20SQL=20cod?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../habbohotel/guilds/forums/ForumThread.java | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java index a82a2d01..f7d9a65e 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java @@ -135,16 +135,10 @@ public class ForumThread implements Runnable, ISerialize { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT A.*, B.`id` AS `last_comment_id` " + "FROM guilds_forums_threads A " + - "JOIN (" + - "SELECT * " + + "LEFT JOIN (" + + "SELECT `thread_id`, MAX(`id`) AS `id`, MAX(`created_at`) AS `created_at` " + "FROM `guilds_forums_comments` " + - "WHERE `id` IN (" + - "SELECT MAX(id) " + - "FROM `guilds_forums_comments` B " + - "GROUP BY `thread_id` AND B.`id` " + - "ORDER BY B.`id` " + - ") " + - "ORDER BY `id` DESC " + + "GROUP BY `thread_id`" + ") B ON A.`id` = B.`thread_id` " + "WHERE A.`guild_id` = ? " + "ORDER BY A.`pinned` DESC, B.`created_at` DESC " @@ -176,16 +170,10 @@ public class ForumThread implements Runnable, ISerialize { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement( "SELECT A.*, B.`id` AS `last_comment_id` " + "FROM guilds_forums_threads A " + - "JOIN (" + - "SELECT * " + + "LEFT JOIN (" + + "SELECT `thread_id`, MAX(`id`) AS `id`, MAX(`created_at`) AS `created_at` " + "FROM `guilds_forums_comments` " + - "WHERE `id` IN (" + - "SELECT MAX(id) " + - "FROM `guilds_forums_comments` B " + - "GROUP BY `thread_id` AND b.`id`" + - "ORDER BY B.`id` " + - ") " + - "ORDER BY `id` DESC " + + "GROUP BY `thread_id`" + ") B ON A.`id` = B.`thread_id` " + "WHERE A.`id` = ? " + "ORDER BY A.`pinned` DESC, B.`created_at` DESC " +