vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Question about query syntax (https://vborg.vbsupport.ru/showthread.php?t=79931)

Robert Basil 04-14-2005 07:03 PM

Question about query syntax
 
I'm trying to pull the last 3 posts from a few forums and then sort the by the forum's name. Here is what I have so far:

SELECT t.threadid, t.title, t.firstpostid, t.lastpost, f.title as forumtitle, t.replycount, t.postusername, t.postuserid, t.lastposter, t.dateline, t.views, p.pagetext, t.iconid, t.forumid
FROM thread t
LEFT JOIN post p ON p.postid = t.firstpostid
LEFT JOIN forum f ON f.forumid = t.forumid
WHERE t.forumid
IN ( 19, 116 )
AND t.open = '1'
AND t.visible = '1'
ORDER BY forumtitle DESC
LIMIT 0 , 3

The code above only pull 3 total posts from the forums, any ideas on how to pull the last 3 posts from each forum?

Thanks in advance!

tnguy3n 04-14-2005 11:29 PM

Assuming you'd put this code bit in forumdisplay.php file.

PHP Code:

SELECT forum.forumidforum.title AS forumtitlethread.*, post.* 
    
FROM " . TABLE_PREFIX . " thread AS thread
    LEFT JOIN 
" . TABLE_PREFIX . "forum AS forum ON(forum.forumid thread.forumid)
    
LEFT JOIN " . TABLE_PREFIX . "post AS post ON(thread.lastpost post.postid)
    
WHERE thread.forumid '" . intval($forumid) . "'
    
AND thread.visible 1
    ORDER BY forumtitle
    LIMIT 0


Quote:

Originally Posted by Sportbikeworld
I'm trying to pull the last 3 posts from a few forums and then sort the by the forum's name. Here is what I have so far:

SELECT t.threadid, t.title, t.firstpostid, t.lastpost, f.title as forumtitle, t.replycount, t.postusername, t.postuserid, t.lastposter, t.dateline, t.views, p.pagetext, t.iconid, t.forumid
FROM thread t
LEFT JOIN post p ON p.postid = t.firstpostid
LEFT JOIN forum f ON f.forumid = t.forumid
WHERE t.forumid
IN ( 19, 116 )
AND t.open = '1'
AND t.visible = '1'
ORDER BY forumtitle DESC
LIMIT 0 , 3

The code above only pull 3 total posts from the forums, any ideas on how to pull the last 3 posts from each forum?

Thanks in advance!


Robert Basil 04-15-2005 09:50 PM

Quote:

Originally Posted by tnguy3n
Assuming you'd put this code bit in forumdisplay.php file.

PHP Code:

SELECT forum.forumidforum.title AS forumtitlethread.*, post.* 
    
FROM " . TABLE_PREFIX . " thread AS thread
    LEFT JOIN 
" . TABLE_PREFIX . "forum AS forum ON(forum.forumid thread.forumid)
    
LEFT JOIN " . TABLE_PREFIX . "post AS post ON(thread.lastpost post.postid)
    
WHERE thread.forumid '" . intval($forumid) . "'
    
AND thread.visible 1
    ORDER BY forumtitle
    LIMIT 0



The code above will not work.

I'm not putting it into the forumdisplay.php file, I'm putting it into the query box with Logician's hack:

WebTemplates 3.x: VB Integrated Content Management System

Link to my question (and some ideas I have tried) in that thread.

https://vborg.vbsupport.ru/showthrea...267#post641267

I've also tried using the ORDER BY query option but no luck.

Thanks for the try anyway. :)

Any other ideas?


All times are GMT. The time now is 01:42 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01619 seconds
  • Memory Usage 1,730KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete