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 5976771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:16:32+00:00 2026-05-22T21:16:32+00:00

Following the answer from this post , I have something like this: update MyTable

  • 0

Following the answer from this post, I have something like this:

update MyTable
set column1 = otherTable.SomeColumn,
    column2 = otherTable.SomeOtherColumn
from MyTable
inner join
(select *some complex query here*) as otherTable
on MyTable.key_field = otherTable.key_field;

However, I keep getting this error:

The column prefix ‘otherTable’ does
not match with a table name or alias
name used in the query.

I’m not sure what’s wrong. Can’t I do such an update from a select query like this?
Any help would be greatly appreciated.

(I’m using *blush* sql server 2000.)

EDIT:

here’s the actual query

update pdx_projects set pr_rpc_slr_amount_year_to_date = summary.SumSLR, pr_rpc_hours_year_to_date = summary.SumHours
    from pdx_projects pr join (
select  pr.pr_pk pr_pk, sum(tc.stc_slr_amount)  SumSLR, sum(tc.stc_worked_hours)  SumHours from pdx_time_and_cost_from_rpc tc 
    join pdx_rpc_projects sp on tc.stc_rpc_project_id = sp.sol_rpc_number
    join pdx_rpc_links sl on sl.sol_fk = sp.sol_pk
    join pdx_projects pr on pr_pk = sl.pr_fk
    where tc.stc_time_card_year = year(getdate())
    group by pr_pk
) as summary

on pr.pr_pk = summary.pr_pk

and the actual error message is

Server: Msg 107, Level 16, State 2,
Line 1 The column prefix ‘summary’
does not match with a table name or
alias name used in the query.

  • 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-22T21:16:33+00:00Added an answer on May 22, 2026 at 9:16 pm

    I submit to you this altered query:

    update x
    set x.pr_rpc_slr_amount_year_to_date = summary.sumSLR, 
        x.pr_rpc_hours_year_to_date = summary.sumHours
    from pdx_projects x
    join (
        select  pr.pr_pk as pr_pk, 
                sum(tc.stc_slr_amount) as SumSLR, 
                sum(tc.stc_worked_hours) as SumHours 
        from pdx_time_and_cost_from_rpc tc 
        join pdx_rpc_projects sp on tc.stc_rpc_project_id = sp.sol_rpc_number
        join pdx_rpc_links sl on sp.sol_pk = sl.sol_fk
        join pdx_projects pr on sl.pr_fk = pr.pr_pk
        where tc.stc_time_card_year = year(getdate())
        group by pr.pr_pk
    ) as summary
    on x.pr_pk = summary.pr_pk
    

    Notably different here: I don’t re-use the alias pr inside and outside of the complex query. I re-ordered the joins the way I like them (previously referenced table first,) and explicitly notated pr_pk in 2 places. I also changed the update syntax to use update <alias>.

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

Sidebar

Related Questions

I have followed the Accepted Answer's instructions from this post as regards creating a
I have created a 3d map using rgl.surface(), mainly following Shane's answer in this
Update I have posted my solution to this problem as an answer below. It
In my answer from yesterday I called the following piece of code a hack:
How do you answer the following questions from managers, testers and other people in
NOTE: XMLIgnore is NOT the answer! OK, so following on from my question on
I tried following the answer to this question , but could not get xsd.exe
I am trying out the code from this post on Event Driven Architecture (very
this kind of follows on from another question of mine. Basically, once I have
I have the following .htaccess at the moment. This is a dummy copy paste

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.