Oracle Database
--
Questions
--
Followers
Top Experts
The following update statement works fine in SQL Server:
UPDATE BETA
SET BETAID= A.ALPHAID
FROM TABLE BETA
INNER JOIN ALPHA A
ON BETAID= A.ALPHADESC
So using the lookup table Alpha:-
ALPHAID ALPHADESC
1 First
2 Second
3 Third
This changes the Beta table from:-
BETAID
First
Second
Third
To:-
BETAID
1
2
3
So, the query is simply using a lookup table to replace a description with its corresponding ID, one row at a time. I now need to replicate this query in Oracle. Using the following:-
UPDATE BETA
SET BETAID = (SELECT A.ALPHAID FROM ALPHA A, BETA B
WHERE B.BETAID = A.ALPHADESC);
Results in 'single-row subquery returns more than one row', as expected. How would I rewrite this query for oracle?
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
UPDATE BETA
SET BETAID = (SELECT MAX(A.ALPHAID) FROM ALPHA A, BETA B
WHERE B.BETAID = A.ALPHADESC);
---
Harish






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Is the 'inner join syntax' supported in oracle. If so does it differ from the SQL Server standard?
But I think you need to remove "TABLE" from your SQL query..
UPDATE BETA SET BETAID= A.ALPHAID
FROM BETA INNER JOIN ALPHA A
ON BETAID= A.ALPHADESC

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
UPDATE BETA
SET BETAID= (select ALPHAID from alpha where betaid = alphadescr)
where exists (select ALPHAID from alpha where betaid = alphadescr)






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
UPDATE beta b
SET b.betaid = (SELECT a.alphaid
FROM alpha a
WHERE a.alphadesc = b.betaid)
If there dupes then this will work:
UPDATE beta b
set b.betaid = (SELECT a.alphaid
FROM (SELECT a.alphaid,a.alphadesc
FROM alpha a
GROUP BY a.alphaid,a.alphadesc) a
WHERE a.alphadesc = b.betaid)
set beta.betaid = (select alpha.alphaid from alpha
where beta.betaid = alpha.alphadesc);

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Sure, you can achieve the same thing in Oracle as well, in which case you'll just need to modify the above mentioned query to include the join conditions.
UPDATE BETA
SET BETAID = (SELECT max(A.ALPHAID) FROM ALPHA A, BETA B
WHERE B.BETAID = A.ALPHADESC)
and exists (select 'x' from alpha a, beta b where b.betaid=a.alphadesc);
Oracle Database
--
Questions
--
Followers
Top Experts
Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.