?
Solved

Invalid Column Name on Inner Join

Posted on 2006-04-28
5
Medium Priority
?
575 Views
Last Modified: 2012-08-14
SELECT     TOP 10 dbo.CDS_GROUPENROLL.Player_ID AS player_id, dbo.CDS_GROUP.Group_ID AS group_id,
                      dbo.CDS_GROUP.GroupName AS group_name
FROM         dbo.CDS_GROUPENROLL INNER JOIN
                      dbo.CDS_GROUP ON dbo.CDS_GROUPENROLL.Group_ID = dbo.CDS_GROUP.Group_ID
WHERE     (dbo.CDS_GROUP.GroupName = [May 800])
ORDER BY dbo.CDS_GROUPENROLL.Player_ID

I receive Invalid Column Name [May 800].  So how do I write this join to only grap the field where the group name is equal to strings that I provide?
0
Comment
Question by:bgarrabrant
5 Comments
 
LVL 9

Expert Comment

by:udayshankar
ID: 16564504
did you try putting may 800 in quotes?
what is the datatype of that field?
0
 
LVL 9

Expert Comment

by:udayshankar
ID: 16564507
try like '%may 800%'
0
 
LVL 44

Accepted Solution

by:
bruintje earned 1500 total points
ID: 16564700
Hello bgarrabrant,

you have the May 800 in brackets that is saying to SQL Server that it is a column name

you could try it with 'May 800'

SELECT     TOP 10 dbo.CDS_GROUPENROLL.Player_ID AS player_id, dbo.CDS_GROUP.Group_ID AS group_id,
                      dbo.CDS_GROUP.GroupName AS group_name
FROM         dbo.CDS_GROUPENROLL INNER JOIN
                      dbo.CDS_GROUP ON dbo.CDS_GROUPENROLL.Group_ID = dbo.CDS_GROUP.Group_ID
WHERE     (dbo.CDS_GROUP.GroupName = 'May 800')
ORDER BY dbo.CDS_GROUPENROLL.Player_ID


hope this helps a bit
bruintje
0
 
LVL 27

Expert Comment

by:ptjcb
ID: 16564778
Or you could use a local variable...

DECLARE @GrpName nvarchar(10)

SET @GrpName = 'May 800'

SELECT     TOP 10 dbo.CDS_GROUPENROLL.Player_ID AS player_id, dbo.CDS_GROUP.Group_ID AS group_id,
                      dbo.CDS_GROUP.GroupName AS group_name
FROM         dbo.CDS_GROUPENROLL INNER JOIN
                      dbo.CDS_GROUP ON dbo.CDS_GROUPENROLL.Group_ID = dbo.CDS_GROUP.Group_ID
WHERE     (dbo.CDS_GROUP.GroupName =@GrpName)
ORDER BY dbo.CDS_GROUPENROLL.Player_ID
0
 

Author Comment

by:bgarrabrant
ID: 16566245
Single quotes is what did the trick.  Thanks!
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

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

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

588 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