Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我正在构建的论坛中,我想获取有关在线程中发布帖子的用户的信息。例如,来自表格 ForumSettings 的签名、他们的论坛排名、帖子数量等。我在一个带有 ID 的表中有线程列表,并且我在一个单独的表中有帖子,其中一个 threadID 列链接到 ThreadList 表。使用 PHP,我怎样才能有效地获取有关用户的信息以显示在他们发布的每个帖子旁边?
假设您正在加载 id = 5 的线程
SELECT u.`name`, u.`signature`, u.`rank`, COUNT(*) as numPosts FROM `users` u INNER JOIN `posts` p ON (u.`id` = p.`userId`) WHERE u.`id` IN ( SELECT `userId` FROM `posts` WHERE `threadId` = 5 ) GROUP BY u.`name`, u.`signature`, u.`rank`