We help IT Professionals succeed at work.
Get Started

Updating specific rows

354 Views
Last Modified: 2014-05-05
Hello,
I have an update query that seems to be updating the records in reverse.
I am trying to update a column that has a value of '0' or a NULL.
I need to update these rows with a default value from a lookup table.

So when I run the below query, it just does the opposite!  Even with all the joins,
to ensure a specific record does get updated.

I created a temporary table that holds all of the rows that have a - ard_risk_likelyhood
of '0' or NULL.
On the assessment_response_details table, there are like 168k records.
On the temp table, there are like 7k records or rows with a '0' or NULL.

So of the 168k records, there is a value other than '0' or NULL, so these records are good and should not be updated, only those 7k records in question.

When I run the update below, it is updating the 168k records to NULL or the
ard_risk_likelyhood column to null!

What do I need to change, to ensure only the 7k records get updated.

Thanks,

Update  Assessment_Response_Details ard
Set ard.Ard_Risk_Likelyhood =
          (Select Distinct ta.vafmd_Likelyhood
          From tmp_assessments ta
          Where ta.ard_id = ard.ard_id
          And ta.ard_aqb_id = ard.ard_aqb_id
          And ta.ard_arh_id = ard.ard_arh_id
          And ard.Ard_Risk_Likelyhood In (0, null));

Using - Windows OS and Oracle 11g
Comment
Watch Question
CERTIFIED EXPERT
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE