[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

SELECT FROM WHERE error message

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)
1 Solution
type it like this:

 (dbo.Inventory.InvtID = 'NOTES')
James MurrellProduct SpecialistCommented:
Un your results that work what is in first column..... ie.  234
Paul JacksonCommented:
Use single quotes :

WHERE     (dbo.Inventory.InvtID = 'NOTES')
Ephraim WangoyaCommented:

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?
Deerhunter19Author 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.

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now