Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 12 May 2016, 14:35
kgroneman's Avatar
kgroneman kgroneman is offline
 
Join Date: Aug 2007
Question Excluding forums in SQL query

I need some help with an SQL query. I'm trying to run a query to list the top posters but exclude some specific forums using vb_forumid, but it's not recognized. Here's the query BEFORE trying to exclude forums that works fine:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

When I add the forum IDs to exclude, I get the following error:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Here is the query that produces the error:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I have another forum where I don't use the vb_ prefix (so it's just forumid, not vb_forumid) and the query runs fine so I don't get why this doesn't work on my prefixed forum. Help?
Reply With Quote
  #2  
Old 12 May 2016, 14:59
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave
Column names aren't prefixed, only table names are.
Change vb_forumid to forumid.
__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.
Reply With Quote
  #3  
Old 12 May 2016, 15:11
kgroneman's Avatar
kgroneman kgroneman is offline
 
Join Date: Aug 2007
Thanks Dave, that's what I thought too, but when I use just forumid I get the same error:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Any other ideas? Oh interesting...on a different query, forumid works. I wonder why not on this query? Off to try some other things but if you have any ideas, they would be most appreciated.
Reply With Quote
  #4  
Old 12 May 2016, 15:20
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave
The post table does not contain a column called forumid, you'd have to LEFT JOIN the thread table.
So add LEFT JOIN vb_thread ON vb_thread.threadid = vb_post.threadid and change forumid to vb_thread.forumid.
__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.
Reply With Quote
  #5  
Old 12 May 2016, 15:40
kgroneman's Avatar
kgroneman kgroneman is offline
 
Join Date: Aug 2007
First of all THANK YOU so much for your time and effort helping me. I don't know much of anything about SQL queries. I tried your suggestion and got a timestamp error, so I changed the syntax of the date line, with the same error:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The error is:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So for some reason, making the changes you suggested changed the way it reads the date, and I'm not nearly smart enough to figure out why. :-\
Reply With Quote
  #6  
Old 12 May 2016, 15:43
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Originally Posted by kgroneman View Post
First of all THANK YOU so much for your time and effort helping me. I don't know much of anything about SQL queries. I tried your suggestion and got a timestamp error, so I changed the syntax of the date line, with the same error:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The error is:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So for some reason, making the changes you suggested changed the way it reads the date, and I'm not nearly smart enough to figure out why. :-\
When two tables have columns with the same name and you want to refer to one of them you need to prefix it with the table name. In your case both thread and post have a dateline column so you'd need to use post.dateline if you wanted the post tables dateline column or thread.dateline if you wanted the thread table dateline column.
Reply With Quote
  #7  
Old 12 May 2016, 15:48
kgroneman's Avatar
kgroneman kgroneman is offline
 
Join Date: Aug 2007
That did it! Thanks to you both! This now works.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I owe you guys...and so fast on the replies! I'm amazed and thankful.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 06:39.

Layout Options | Width: Wide Color: