Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in SQL by (20.3k points)

I have a query which works fine in MySQL, but when I run it on Oracle I get the following error:

SQL Error: ORA-00933: SQL command not properly ended

00933. 00000 - "SQL command not properly ended"

The query is:

UPDATE table1

INNER JOIN table2 ON table1.value = table2.DESC

SET table1.value = table2.CODE

WHERE table1.UPDATETYPE='blah';

1 Answer

0 votes
by (40.7k points)
edited by

The code you have mentioned is not valid in ORACLE.

You can try the code given below:

UPDATE table1 SET table1.value = (SELECT table2.CODE

 FROM table2 

 WHERE table1.value = table2.DESC)

WHERE table1.UPDATETYPE='blah'

AND EXISTS (SELECT table2.CODE

FROM table2 

WHERE table1.value = table2.DESC);

Want to learn SQL from scratch? Here's is the right video for you on SQL provided by Intellipaat

Or else you can use this code:

UPDATE 

(SELECT table1.value as OLD, table2.CODE as NEW

 FROM table1

 INNER JOIN table2

 ON table1.value = table2.DESC

 WHERE table1.UPDATETYPE='blah'

) t

SET t.OLD = t.NEW

Related questions

+3 votes
1 answer
asked Jul 3, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
1 answer
asked Jan 7, 2021 in SQL by Appu (6.1k points)

Browse Categories

...