Erin
Erin

Reputation: 495

"Invalid character" error with Oracle11g, potentially thrown by _?

So I am using Oracle SQL, looking to answer this question: "4. (10 Points) List all customers who are ordering equipment whose description begins with ‘tennis’ or ‘volleyball’. List the Customer number, Stock number, and Description. Do not repeat any rows."

With this query:

SELECT c.customer_num, s.stock_num, s.description
FROM customer c, stock s
WHERE s.description LIKE %tennis%
OR s.description LIKE %volleyball%
GROUP BY c.customer_num;

The customer table schema is: customer_table_schema

And the stock table schema is: stock_table_schema

My error looks like this:

underscore_error

It looks like SQL doesn't like the "_" character? But I ran my first query (which included underscores) with no issues. I tried adding parentheses and re-formatting the query but I have to use the underscore since that's what the table column name is. I haven't been able to find anything online that talks about this error. Any ideas as to what's going on here? Or any troubleshooting techniques I could try?

Thank you!

Upvotes: 0

Views: 75

Answers (1)

pmdba
pmdba

Reputation: 7043

Do not confuse spell checker warnings with syntax errors. You need to put single quotes around your search values:

e.g. s.description like '%tennis%'

Upvotes: 1

Related Questions