Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update statement updating all records

Status
Not open for further replies.

cuetzpalin

Programmer
Jun 5, 2002
99
US
Hi,

I'm running an update statement that should only update certain records but instead is updating all! Please help.

Here's my code:
UPDATE NC_NET_CLMS_FINAL_V4
SET DESCRIPTION = 'REIMBURSE/LIS-RETRO REFUND'
WHERE EXISTS
(SELECT DISTINCT
NC_NET_CLMS_FINAL_V4.*
FROM
NC_NET_CLMS_FINAL_V4, NC_LIS_RETRO_REFUNDS
WHERE
LPAD(NC_NET_CLMS_FINAL_V4.MR,12,'0') = LPAD(NC_LIS_RETRO_REFUNDS.MR#,12,'0')
)

it's updating all rows instead of the 10 I need updated.

Thanks!
 
Provide the table structure of the table to be ipdated and the select statement which would produce the 10 records in question

-- Jason
"It's Just Ones and Zeros
 
Your sub-query is not correlated. It is a SELECT in its own right and if it is true for one row it will be true for every row.

Try this:
Code:
UPDATE NC_NET_CLMS_FINAL_V4 n1
SET    n1.DESCRIPTION = 'REIMBURSE/LIS-RETRO REFUND'
WHERE EXISTS
(SELECT 1
 FROM   NC_LIS_RETRO_REFUNDS r1
 WHERE  LPAD(n1.MR,12,'0') = LPAD(r1.MR#,12,'0') )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top