Reputation: 35
I am just beginning an SQL class and am having issues with one of the problems I must do. The question is
Use the IN operator to list the part number and part description of each part in item class AP or SG.
What I have for the answer is
SELECT PART_NUM, DESCRIPTION
FROM PART
WHERE CLASS IN (AP, SG);
If I try to run that it states that SG is an invalid identifier. But if I view the table there are classes that = both ap and sg. does anyone have any assistance as to what I am doing incorrectly? Thanks for your time
Upvotes: 1
Views: 282
Reputation: 188
Only int values can be written without quotes for char and varchar datatypes, you need to use quotes and hence the values AP and SG must be provided in quotes like below :
SELECT PART_NUM, DESCRIPTION
FROM PART
WHERE CLASS IN ('AP','SG');
Upvotes: 0
Reputation: 453
I think you're just missing quotes - try:
WHERE CLASS IN ('AP', 'SG');
Upvotes: 0
Reputation: 998
Quote the values 'AP','SG' as they are chars.
... in ('AP','SG')
Upvotes: 1
Reputation: 18257
if class is an attribute of type varchar2
o varchar
you should run sql like this
SELECT PART_NUM, DESCRIPTION
FROM PART
WHERE CLASS IN ('AP', 'SG');
Notice that putting a '
on each element
Upvotes: 3