We help IT Professionals succeed at work.

SELECT FROM WHERE error message

Deerhunter19
Deerhunter19 asked
on
Medium Priority
385 Views
Last Modified: 2012-06-27
Here is the query.  It runs without the WHERE and returns the error "Invalid column name NOTES" when run with the WHERE.  I enter WHERE InvtID = "NOTES" and it changes the syntax to what is below when I execute.  I am expecting this to be an easy answer since I am very new to SQL.

SELECT     dbo.Inventory.InvtID, dbo.Inventory.Descr, dbo.Inventory.User6 AS QytPDQ, dbo.Inventory.ClassID, dbo.InventoryADG.ProdLineID, dbo.Inventory.ProdMgrID, dbo.Item2Hist.PTDQtySls00 AS Jan, dbo.Item2Hist.PTDQtySls01 AS Feb, dbo.Item2Hist.PTDQtySls02 AS Mar, dbo.Item2Hist.PTDQtySls03 AS Apr, dbo.Item2Hist.PTDQtySls04 AS May, dbo.Item2Hist.PTDQtySls05 AS Jun, dbo.Item2Hist.PTDQtySls06 AS Jul, dbo.Item2Hist.PTDQtySls07 AS Aug, dbo.Item2Hist.PTDQtySls08 AS Sep, dbo.Item2Hist.PTDQtySls09 AS Oct, dbo.Item2Hist.PTDQtySls10 AS Nov,  dbo.Item2Hist.PTDQtySls11 AS Dec, dbo.Item2Hist.FiscYr

FROM         dbo.Inventory INNER JOIN
                      dbo.Item2Hist ON dbo.Inventory.InvtID = dbo.Item2Hist.InvtID INNER JOIN
                      dbo.InventoryADG ON dbo.Inventory.InvtID = dbo.InventoryADG.InvtID

WHERE     (dbo.Inventory.InvtID = NOTES)
Comment
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
James MurrellQA Product Specialist
CERTIFIED EXPERT

Commented:
Un your results that work what is in first column..... ie.  234
Paul JacksonSoftware Engineer
CERTIFIED EXPERT
Top Expert 2011

Commented:
Use single quotes :

WHERE     (dbo.Inventory.InvtID = 'NOTES')
Ephraim WangoyaSoftware Engineer
CERTIFIED EXPERT

Commented:

WHERE     (dbo.Inventory.InvtID = NOTES)
This expects one of your tables to have a field called NOTES

WHERE     (dbo.Inventory.InvtID = 'NOTES')
This will compare the value of InvtID to the value 'NOTES'

What are you trying to do with the query?

Author

Commented:
I knew that was going to be easy and I stumbled across it myself.  I came back to pull the question and see that it had been answered.  I have chosen to award the points to the first answer submitted and am hoping that seems fair.  Thank you all very much.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.