Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question.

Asked: May 25, 2022 - 7:05 am UTC

Last updated: August 04, 2023 - 5:32 am UTC

Version: 18

Viewed 10K+ times! This question is

You Asked

Hi Tom, i get this error: SQL Error: ORA-00933-00000 - "SQL command not properly ended" when i run this query:

update a
set propertyaddress = nvl2(a.propertyaddress, b.propertyaddress,b.propertyaddress)
from nashvillehousing a
join nashvillehousing b
on a.parcelid = b.parcelid
and a.uniqueid_ != b.uniqueid_
where a.propertyaddress is null


trying to populate property address where its null.

and Chris said...

Direct join syntax is unsupported in Oracle Database; use a correlated subquery to fetch the values instead.

For example:

update nashvillehousing a
set propertyaddress = ( 
  select nvl2(a.propertyaddress, b.propertyaddress,b.propertyaddress)
  from   nashvillehousing b
  where  a.parcelid = b.parcelid
  and   a.uniqueid_ != b.uniqueid_
)
where a.propertyaddress is null

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

As of 23c, this is now supported

Theron Knapp, August 01, 2023 - 7:26 pm UTC

If you are able to use v23c, the ANSI join syntax with UPDATE statement will now work.

https://www.youtube.com/watch?v=-1sbSfYTVo0

Connor McDonald
August 04, 2023 - 5:32 am UTC

Awesome video :-)

More to Explore

SQL

The Oracle documentation contains a complete SQL reference.