[askdba] Re: UPDATE SQL

  • From: "Justin Cave (DDBC)" <jcave@xxxxxxxxxxx>
  • To: <askdba@xxxxxxxxxxxxx>, <oracle-l@xxxxxxxxxxxxx>
  • Date: Wed, 13 Oct 2004 07:23:35 -0600

Assuming a 1-to-1 relationship, I would think you would want

UPDATE profile_customers profile_cust
   SET sp_type_cd =3D (SELECT sp_type_cd
                       FROM profile_sp_type_cd profile_cd
                      WHERE profile_cust.sp_type_cd =3D

This will update every row in profile_customers, updating the column to
NULL if there is no matching row in profile_sp_type_cd.  If you only
want to update profile_customer rows when there is a match, you can add
a WHERE EXISTS clause to the UPDATE statement.

Justin Cave  <jcave@xxxxxxxxxxx>
Distributed Database Consulting, Inc.

-----Original Message-----
From: askdba-bounce@xxxxxxxxxxxxx [mailto:askdba-bounce@xxxxxxxxxxxxx]
On Behalf Of Chirag DBA
Sent: Wednesday, October 13, 2004 7:17 AM
To: askdba@xxxxxxxxxxxxx; oracle-l@xxxxxxxxxxxxx
Subject: [askdba] UPDATE SQL

Hi Friends,=20

I wanna update values of SP_TYPE_CD in PROFILE_CUSTOMERS which has a
VALUES and I wanna put the SP_TYPE_CD from PROFILE_SP_TYPE_CD.

PROFILE_SP_TYPE_CD  is a master table and PROFILE_CUSTOMERS is a child

I have written the following query.

update profile_customers  set SP_TYPE_CD =3D =

where profile_customers.sp_type_cd =3D profile_sp_type_cd.sp_type_name;

I don wanna run seperate queries for each row in PROFILE_SP_TYPE_CD.
Cause my PROFILE_CUSTOMERS have more than 50000 records and this will
be the pump running every nite.

Can I update that in a single SQL Statement?

 - Chiku

Other related posts: