[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

GRRR!! Column prefix does not match with table name or alias name used in the query, help!!

Posted on 2004-10-25
4
Medium Priority
?
1,888 Views
Last Modified: 2012-06-27
Hey guys / gals.. I've got this little problem that is just more annoying that anything else and i'm curious to see how I could get it fixed.... any and all help will be appreciated!

SELECT SubUser.firstName as submitted_by_firstname, SubUser.lastName as submitted_by_lastname,
ComplUser.firstName as completed_by_firstname, ComplUser.lastName as completed_by_lastname,
RE.neededBy, RE.submittedBy, RE.spacenum, RE.shoppingCenter, RE.requiredOptions,
RE.phone, RE.description, RE.tenantName, RE.devContact, RE.address, RE.city, RE.state, RE.zip
FROM request R, revision RE
inner join users SubUser ON RE.submittedBy = SubUser.userID
inner join users ComplUser ON R.completedBy = ComplUser.userID
inner join R ON RE.requestID = R.requestID
WHERE RE.revisionID = 63;

When I run the above query I keep getting this error message:

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


I've gone through and double checked that I have used the appropriate alias  everytime I have referred to that specific table in this query... this is really driving me nuts! I've had this happen before and I can't remember why it happens and/or how I fixed it. Just for future concern... why is this happening so I can avoid this? I know it's probably something small!

Thanks!!!

0
Comment
Question by:edensandavant
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 32

Accepted Solution

by:
Brendt Hess earned 500 total points
ID: 12404503
Your WHERE clause was hosed.  I have reformatted the query for clarity, and annotated my changes:

SELECT SubUser.firstName as submitted_by_firstname,
      SubUser.lastName as submitted_by_lastname,
      ComplUser.firstName as completed_by_firstname,
      ComplUser.lastName as completed_by_lastname,
      RE.neededBy,
      RE.submittedBy,
      RE.spacenum,
      RE.shoppingCenter,
      RE.requiredOptions,
      RE.phone,
      RE.description,
      RE.tenantName,
      RE.devContact,
      RE.address,
      RE.city,
      RE.state,
      RE.zip
FROM revision RE                                                                        -- Removed request R, from this line.  Join is below
inner join users SubUser ON RE.submittedBy = SubUser.userID
inner join request R ON RE.requestID = R.requestID                         -- Added name of table here
inner join users ComplUser ON R.completedBy = ComplUser.userID   -- reorganized - moved line down
WHERE RE.revisionID = 63
0
 

Author Comment

by:edensandavant
ID: 12404552
That was quick!
Thanks for the answer... after 4 advil I can put this issue to rest :)
0
 
LVL 32

Expert Comment

by:Brendt Hess
ID: 12404626
Rule of thumb:

Don't mix the join forms (explicit INNER JOIN vs Table1, table2 WHERE) -- it always ends up causing problems.  I strongly recommend always using the explicit joins, to make the join sequence clearer.
0
 
LVL 4

Expert Comment

by:Wardy_01
ID: 24385705
I'm having the same problem ...
I get this :
Msg 107, Level 16, State 2, Line 2
The column prefix 'tvbc_ch_live.dbo' does not match with a table name or alias name used in the query.

From this query :
INSERT INTO tvbc_ch_live.dbo.property (class, uprn, blpu, east, north, rb_propref, post_code, ctax_band, parish, address_status, address_type, ward, street, p_start_no, p_end_no, p_start_suffix, p_end_suffix, p_desc, s_start_no, s_end_no, s_start_suffix, s_end_suffix, s_desc, po_box, display_address, residential, business, addressable, parent, land_use, candidate, abc_exclude, organisation)
SELECT class, uprn, blpu, east, north, rb_propref, post_code, ctax_band, parish, address_status, address_type, ward, street, p_start_no, p_end_no, p_start_suffix, p_end_suffix, p_desc, s_start_no, s_end_no, s_start_suffix, s_end_suffix, s_desc, po_box, display_address, residential, business, addressable, parent, land_use, candidate, abc_exclude, organisation
FROM tvbc_ch_test.dbo.property
WHERE NOT EXISTS (
      SELECT 1 FROM tvbc_ch_live.dbo.property
      WHERE tvbc_ch_live.dbo.surrid = tvbc_ch_test.dbo.property.surrid
)

........

HELP !!!
It's something obvious i'm betting :(
Sorry if I hijacked the thread but i figured this is relevant as it's the same kind of error, what does this error even mean anyway?
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question