0

I want to show first_name, last_name columns and make UPPER-CASE LETTERS for those entries who have the letter 's' in the last name.

I am getting

ORA-00933: SQL command not properly ended

error. Anyone has an idea where I go wrong and How do I fix it?

SELECT first_name, last_name FROM CUSTOMERS 
WHERE last_name LIKE "S"
UPDATE CUSTOMERS 
SET 
    first_name = UPPER(first_name)
    last_name = UPPER(last_name)
1
  • You can do either SELECT or UPDATE. Not both at the same time. Commented Nov 21, 2020 at 21:20

3 Answers 3

0

You seem to want:

UPDATE CUSTOMERS 
SET first_name = UPPER(first_name), last_name = UPPER(last_name)
WHERE last_name LIKE '%S%'

It is unclear whether you want to match on upper-case or lower-case "s" in the name. If you want both, then:

WHERE UPPER(last_name) LIKE '%S%'
Sign up to request clarification or add additional context in comments.

2 Comments

It fixed making the last names uppercase but can I also show/view the columns first name and last name in the same code?
@Adam: you can't SELECT and UPDATE at the same time in Oracle.
0

try putting "%S" instead of "S". If you put "S" it will only show you results for surnames that are just the letter S

2 Comments

Possibly you mean "%S%"
Yeah, you're right if you put "%S" it shows you the names that end with S. If you put "%S%" it will display the names that have the letter S inside
0

Try following with subquery:-

UPDATE  CUSTOMERS 
SET  ( first_name ,    last_name ) = (SELECT  UPPER(first_name) ,  UPPER(last_name)  FROM CUSTOMERS   )
WHERE UPPER(last_name)  LIKE 'S'

However, if you want all last_name starting with S then add wildcard such as

WHERE UPPER(last_name) LIKE 'S%' 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.