Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error: "invalid column name.."

Status
Not open for further replies.

dt2demar

Technical User
Nov 20, 2000
32
CA
I wrote a query for MS SQL.

The basic structure is:

SELECT DISTINCT
TABLEA.FIELDA
TABLEA.FIELDB
FIELDC=
CASE
WHEN TABLEA.FIELDA LIKE "X" THEN "TRUE"
WHEN TABLEA.FIELDA LIKE "Y" THEN "FALSE"
ELSE
NULL
END,

FROM...

INTO...

WHERE... etc.

I get an error that says "invalid column name 'FIELDC'". What is the problem
here? FieldC is the new field I created. Do I have to initialize it or
something? Any help would be apprciated. Thanks.
 
Maybe you meant:

SELECT DISTINCT
TABLE1.FIELD1,
TABLE1.FIELD2,FIELDC=
CASE
WHEN TABLEA.FIELDA LIKE 'X' THEN 'TRUE'
WHEN TABLEA.FIELDA LIKE 'Y' THEN 'FALSE'
ELSE
NULL
END
FROM TABLE1
WHERE CONDITION1,CONDITIONN...

You forgot the colons between the fields and put a colon just before "From" clause
If that is not the error please write the query again.


Edwin Dalorzo
edalorzo@hotmail.com

 

I had included the comma's after 'TABLEA.FIELDA' and 'TABLEA.FIELDB'. It should read as follows, but still has an error of "invalid column name 'FIELDC'".

SELECT DISTINCT
TABLEA.FIELDA,
TABLEA.FIELDB,
FIELDC=
CASE
WHEN TABLEA.FIELDA LIKE "X" THEN "TRUE"
WHEN TABLEA.FIELDA LIKE "Y" THEN "FALSE"
ELSE
NULL
END,

FROM...

INTO...

WHERE... etc.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top