0
votes

I'm trying to make an update query with a join statement. however, it keeps throwing an error of syntax I'm not really sure where am I going wrong here cause I think I have done it right.

UPDATE AlfaGood 
SET ag.name = 'New text goes here' 
FROM AlfaGood ag 
INNER JOIN SecondAlfa ca ON ca.id = 1 
                         AND ag.agrid = 'Thats my original text';

Please advise on the above if possible. I get an error

ORA-00933: SQL command not properly ended

saying it's missing (; | ,) before FROM

1
Replace UPDATE AlfaGood with UPDATE ag. - Larnu
"missing (; | ,) before FROM"? That isn't a SQL Server error. SQL Server doesn't use Pipes (|). - Larnu
Oracle SQL Developer is an IDE, not an RDBMS. I've corrected the tags for now what we have found out what is really the RDBMS you are using. - Larnu
Does this answer your question? Update statement with inner join on Oracle - Larnu
For future reference, Oracle UPDATE syntax is described here: docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/… - William Robertson

1 Answers

2
votes

You can do this:

UPDATE AlfaGood ag
   SET ag.name = 'New text goes here' 
--FROM AlfaGood ag -- not an Oracle syntax
 WHERE ag.agrid = 'Thats my original text' 
   AND ag.id = 1 
   AND EXISTS ( SELECT ca.id FROM SecondAlfa ca WHERE ca.id = 1 );