0
update cds set numberinstock=numberinstock+3 order by cdname asc

i am using above update command in oracle but it is giving error SQL command not properly ended.

3
  • 1
    an order by in an update statement does not make sense. What are you trying to achieve? Commented May 4, 2014 at 11:14
  • i am trying to update the column in ascending order in cdname ,this command is working in mysql but not in Oracle Commented May 4, 2014 at 11:18
  • "update the column in ascending order in cdname" does not make any sense either. You don't "update in a certain order". You update. And just because MySQL accepts a statement doesn't mean the statement makes sense in the first place. Commented May 4, 2014 at 11:20

1 Answer 1

3

You cannot combine an UPDATE statement with an ORDER BY clause. Update changes the records in a table, ORDER BY is usually used to order the records in a query set (e.g. after a SELECT statement) but not in the DB table itself.

What do you wish to achieve by using ORDER BY in this statement? Consider doing this instead:

UPDATE cds SET numberinstock = numberinstock + 3;

SELECT * FROM cds ORDER BY cdname asc
Sign up to request clarification or add additional context in comments.

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.