Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6830063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:34:26+00:00 2026-05-26T22:34:26+00:00

I realise this is quite a common one, but I’ve been unable to rectify

  • 0

I realise this is quite a common one, but I’ve been unable to rectify it so far after going through the similar issues listed on this site and elsewhere.

Anyway, I have a PHP based app in a forum which allows users to give reputation points to each other, I’m sure you’re all aware how those simple setups work so I won’t dwell on it. The issue is, this bit of code was originally written for MySQL I believe, and while 95% of it has been converted to, and now works, in MS SQL, there remain some queries which seem to crap out on SQL 2005, I suspect due to slight syntax inconsistencies in joins etc. This one has me stuck.
The sample query is as follows:

SELECT TOP 25 p.post_id, p.post_subject, p.forum_id, u.username, u.user_id, 
 u.user_colour, r.rep_id, r.rep_from, r.rep_to, r.rep_time, r.rep_post_id, 
 r.rep_point, r.rep_comment, r.enable_urls, r.rep_ip_address, r.username 
FROM forum_reputations r, forum_users u 
LEFT JOIN forum_posts p ON (r.rep_post_id = p.post_id) 
WHERE r.rep_to = 61
ORDER BY r.rep_id DESC

The data is as follows:

**Forum_Posts**:
post_id (int, PK)
post_subject (varchar)
forum_id (int)

**Forum_users**:
username (varchar)
user_id (int, PK)
user_colour (varchar)

**Forum_reputations**:
rep_id (int, PK)
rep_from (int) 
rep_to (int)
rep_time (int)
rep_post_id (int)
rep_point (int)
rep_comment (text)
enable_urls (int) 
rep_ip_address (varchar) 
username (varchar)

When the query runs, SQL Server spits out the following, familiar error:

[Microsoft][ODBC SQL Server Driver][SQL Server]The multi-part identifier "r.rep_post_id" could not be bound. [37000]

I’m struggling to understand why this is happening. Its obviously insinuating that rep_post_id has a problem but I’ve checked the query syntax and column / table names and they’re all correct, I even tried enclosing any objects that sounded remotely like SQL reserved words in square brackets (i.e u.[username], r.[username] etc), but it makes no difference. Interestingly if I change the FROM clause so Forum_users u is before Forum_users r, the error no longer occurs, and data is returned, but this isn’t much use because it ruins the Left Join and pulls in the top 25 from the users table, ignoring whether they have any associated entries in the reputations table.

The output is supposed to comprise of a table listing the following for each rep entry for a user (r.rep_to):

Number of rep points given (r.rep_point)

User who gave the points (r.rep_from, u.user_id, u.username)

Date points were given (r.rep_time)

Comment entered by user giving the rep points (r.rep_comment)

Forum post that rep was given for (r.rep_post_id, p.post_id, p.post_subject)

If anyone has any thoughts on where this is going wrong or how it can be restructured, I’d greatly appreciate hearing about it. I realise this is probably something very rudimentary but I really can’t see the wood for the trees here!

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:34:27+00:00Added an answer on May 26, 2026 at 10:34 pm

    try

    SELECT TOP 25 p.post_id, p.post_subject, p.forum_id, u.username, u.user_id, 
     u.user_colour, r.rep_id, r.rep_from, r.rep_to, r.rep_time, r.rep_post_id, 
     r.rep_point, r.rep_comment, r.enable_urls, r.rep_ip_address, r.username 
    FROM forum_reputations r
    JOIN forum_users u 
    ON u.user_id = r.rep_from
    LEFT JOIN forum_posts p ON r.rep_post_id = p.post_id 
    WHERE r.rep_to = 61
    ORDER BY r.rep_id DESC
    

    It’s not directly relevant to your question, but a join condition between forum_users and forum_reputation is missing from your query – this will be producing a Cartesian product. I have added a join above, but am guessing a bit as to whether it’s on the right column.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realise this question has been asked before, but after going through the previously
This is a bit of a vague question I realise, but I've been looking
I've found many similar questions but nothing with quite the answer I'm after. Part
I realise this has been asked quite a few times for different languages /
So Heroku has been down all day, of course I didn't realise this until
This is a quite superfluous and uninteresting question, I'm afraid, but I always wonder
I've searched around for answers to this question, but not found anything quite on
I realize that this topic have been brought up sometimes, but I find myself
I realise that this must be a very basic question, but my google-fu seems
I realise this might be a little vague but I honestly don't know where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.