SELECT FROM WHERE error message

Posted on 2011-04-28
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)
Question by:Deerhunter19
    LVL 13

    Accepted Solution

    type it like this:

     (dbo.Inventory.InvtID = 'NOTES')
    LVL 31

    Expert Comment

    by:James Murrell
    Un your results that work what is in first column..... ie.  234
    LVL 29

    Expert Comment

    by:Paul Jackson
    Use single quotes :

    WHERE     (dbo.Inventory.InvtID = 'NOTES')
    LVL 32

    Expert Comment


    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 Closing Comment

    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

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    In this article—a derivative of my blog post (—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
    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.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now