Deerhunter19
asked on
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.ProdLineI D, 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)
SELECT dbo.Inventory.InvtID, dbo.Inventory.Descr, dbo.Inventory.User6 AS QytPDQ, dbo.Inventory.ClassID, dbo.InventoryADG.ProdLineI
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)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Un your results that work what is in first column..... ie. 234
Use single quotes :
WHERE (dbo.Inventory.InvtID = 'NOTES')
WHERE (dbo.Inventory.InvtID = 'NOTES')
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?
ASKER
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.