Home » RDBMS Server » Server Administration » Re: Simple Update
Re: Simple Update [message #374960] Fri, 13 July 2001 16:09
Sudhakar Atmakuru
Messages: 58
Registered: May 2001
Member
Just make sure that the subquery does not return more than one row/value. If it returns more than one value of same, then add DISTINCT verb in the inner SELECT statement should help. Just like this:

UPDATE Table1 T1
SET T1.Field1 = (SELECT DISTINCT T2.Field1
FROM Table2 T2
WHERE T1.Field2 = T2.Field2)

But, and but, even after you added DISTINCT in the subquery and it returns more number of values of different (not same, no duplicates), you better to add another check condition to the inner WHERE clause like T1.Field2 = T2.Field2 AND ...one more condition
Try it out.
Previous Topic: Re: Simple Update
Next Topic: case when end
Goto Forum:
  


Current Time: Sun Jul 07 16:23:00 CDT 2024