Jesse Downing Jesse Downing - 4 months ago 13
SQL Question

SQL Oracle: Where <Col Val> == <Item in a list of characters>

SELECT *
FROM BIG_ASS_DB
where ID in (PLAN4808,LWVL4813,CPPLTXRS,FRBSTXHJ);


The parenthesis contain a list copied from a .txt file. This is a shortened example.
The error I get is:

ORA-00904: "CHWAHKAH": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 3 Column: 9,739


Thanks in advance for your help kind ladies and sirs

Answer

Assuming your ID column is a text column, you need to surround your list elements with quotation marks ' like so 'PLAN4808' as they are text.

Without quotations, SQL is interpreting them as some sort of identifier (as the error message states) for a database object (table, column name, function, et cetera) otherwise.