I am updating a table based on values from another table using the Serial Number field as the common field to look up values. However from below 2 queries i get two different results. Can some one explain why the two outputs are different? Should not the update statement update 47200 records?
UPDATE TBL_SERIAL_NUMBER_MASTER A
SET (A.name) = (SELECT B.name
FROM TBL_DEVICE_LOCALITY B
WHERE A.SERIAL_NUMBER = B.SERIAL_NUMBER AND ROWNUM <=1 )
WHERE EXISTS ( SELECT 1
FROM TBL_DEVICE_LOCALITY
WHERE SERIAL_NUMBER = A.SERIAL_NUMBER
AND TBL_ODIN_DEVICE_LOCALITY.HOST_NAME IS NOT NULL );
Results int: 35,311 rows updated.
select count(*)
from TBL_SERIAL_NUMBER_MASTER A, TBL_DEVICE_LOCALITY B
WHERE A.SERIAL_NUMBER = B.SERIAL_NUMBER AND B.HOST_NAME IS NOT NULL;
Returns: Count = 47200
TBL_ODIN_DEVICE_LOCALITY
in the subquery. I assume this is a typo.