Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4206
Latest: jagwire
New This Month: 0
New This Week: 0
New Today: 0
Stats
Total Posts: 42721
Total Topics: 7443
Most Online Today: 130
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 50
Total: 50

Author Topic: SQL Help  (Read 164 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 663
    • View Profile
    • Homework Clinic - Your Academic Lifeline
SQL Help
« on: October 17, 2022, 09:34:28 pm »
Hello, I am seeking to get a count of topics given the following code. However, it produces over 500,000 topics, which is exhausting the server. I want to limit it to the first 1000 results, but the LIMIT feature isn't working. Apparently there is a solution here, but I can't get it to work.

Do you have any suggestions?

Code: [Select]
$request = db_query("
 SELECT COUNT(DISTINCT t.ID_TOPIC)
 FROM ({$db_prefix}topics AS t, {$db_prefix}boards AS b)
 
INNER JOIN {$db_prefix}messages AS m ON (m.ID_MSG = t.ID_FIRST_MSG)
 
 WHERE b.ID_BOARD = t.ID_BOARD
 AND $query_this_board
 AND m.topicSolved = 0 AND t.ID_FIRST_MSG = t.ID_LAST_MSG", __FILE__, __LINE__);

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16205
    • View Profile
Re: SQL Help
« Reply #1 on: October 17, 2022, 11:12:06 pm »
The first topics in the board or the latest topics? LIMIT should work at the end of the query.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

 

+- Recent Topics

Feature to upload a photo straight when composing a message by SMFHacks
February 04, 2023, 08:13:46 am

Pretty URL's Pro rewriting URLs by [chrisB]
February 01, 2023, 05:18:47 pm

Question before purchase by SMFHacks
February 01, 2023, 03:53:33 pm

Unlimited ending time by Saftek
January 29, 2023, 10:06:26 pm

Converting from Aeva Media by ivanr
January 28, 2023, 10:09:42 am

[Mod] Post Scheduler by bayonetbrant
January 23, 2023, 02:24:09 pm

"Notify all store admins of item purchase" Not Working in SMF 2.1.2 or 2.1.3 by Michael Vail
January 22, 2023, 10:50:23 pm

[Request] Future consideration by [chrisB]
January 18, 2023, 08:42:53 am

Pretty Urls extras by SMFHacks
January 16, 2023, 04:00:57 pm

I don't think its installed correctly by SMFHacks
January 10, 2023, 05:56:21 pm

Powered by EzPortal