vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   What's wrong with this query? (https://vborg.vbsupport.ru/showthread.php?t=76648)

Deaths 02-19-2005 06:41 PM

What's wrong with this query?
 
Whats wrong with this query?

[sql]SELECT * FROM thread WHERE forum.forumid = 13 ORDER BY ID DESC LIMIT 10[/sql]

I get this error:

Code:

Database error in vBulletin 3.0.6:

Invalid SQL:
                SELECT * FROM thread WHERE forum.forumid = 13 ORDER BY ID DESC LIMIT 10
       
mysql error: Unknown table 'forum' in where clause

mysql error number: 1109


Zachery 02-19-2005 06:43 PM

[sql]
SELECT * FROM " . TABLE_PREFIX . "thread WHERE " . TABLE_PREFIX . "forum.forumid = 13 ORDER BY ID DESC LIMIT 10[/sql]

Marco van Herwaarden 02-19-2005 06:49 PM

Lol it is not the only prefix Zach :D He refers to the forum table in the where clause, but forum is not used in the FROM clause. Typical copy&paste&edit error.

[sql]SELECT * FROM " . TABLE_PREFIX . "thread WHERE forumid = 13 ORDER BY ID DESC LIMIT 10[/sql]

Deaths 02-19-2005 07:02 PM

Thanks :).
I don't have time to try this out, but it looks promising.\

Quote:

Typical copy&paste&edit error.
Yep, so many idea's, so little time... If only I had time to handle every idea with the same time and care...

Zachery 02-19-2005 10:30 PM

Quote:

Originally Posted by Deaths
Thanks :).
I don't have time to try this out, but it looks promising.\


Yep, so many idea's, so little time... If only I had time to handle every idea with the same time and care...

I was getting the thing i knew was wrong ;) one at a time ay ? :)

Marco van Herwaarden 02-20-2005 06:47 AM

ay ay

Deaths 02-20-2005 07:34 AM

Ya goo' ol' pirate!

Still didn't work :(.

Query:
PHP Code:


$getnewposts 
$DB_site->query_first("SELECT * FROM " TABLE_PREFIX "thread WHERE forumid = 13 ORDER BY ID DESC LIMIT 10"); 

Error:
Code:

Invalid SQL: SELECT * FROM thread WHERE forumid = 13 ORDER BY ID DESC LIMIT 10
mysql error: Unknown column 'ID' in 'order clause'

mysql error number: 1054


Marco van Herwaarden 02-20-2005 08:13 AM

Hmm ORDER BY threadid or forumid maybe?

Dont know what order you want.

Akex 02-20-2005 08:47 AM

I would say "ORDER BY dateline desc" ;)

But if you want the last posts prefer this one ;)

PHP Code:

$getnewposts $DB_site->query("SELECT p.* FROM " TABLE_PREFIX "post as p
LEFT JOIN " 
TABLE_PREFIX "thread as t ON (t.threadid = p.threadid)
WHERE t.forumid = 13 ORDER BY p.dateline DESC LIMIT 10"
); 


Deaths 02-20-2005 08:54 AM

Ok, now the DB error is gone.

But, with this code:

PHP Code:

$getnewposts $DB_site->query_first("SELECT * FROM " TABLE_PREFIX "thread WHERE forumid = 13 ORDER BY dateline desc LIMIT 10 
"
); 
$newposts number_format($getnewposts['count']); 

It just returns a "0", even though I'm absolutely sure there's a new post in the forum 13...


All times are GMT. The time now is 01:33 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.01747 seconds
  • Memory Usage 1,736KB
  • 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_code_printable
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete