Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4257
Latest: Alex998.
New This Month: 1
New This Week: 0
New Today: 0
Stats
Total Posts: 43293
Total Topics: 7522
Most Online Today: 118
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 86
Total: 86

Author Topic: SQL Help  (Read 790 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
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: 16451
    • 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

Rate own images by fvlog19
April 11, 2024, 10:56:53 am

Tidy Child Boards on 2.1.4 by SMFHacks
April 04, 2024, 03:54:12 pm

Problems SMF 2.0.19 > 2.1.4 SMF Gallery Pro - Recents Images to overall header by Michel68
March 30, 2024, 12:41:08 pm

Can't DROP 'id_member'; check that column/key exists Datei: by SMFHacks
March 30, 2024, 11:58:20 am

No thumbnails on new uploads by Tonyvic
March 29, 2024, 06:26:18 am

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

Powered by EzPortal