The below query is updating all the rows in the table1 eventhough the inner query only selects few of the rows. Any help. Appreciate it. Thanks,

UPDATE table1 out
SET (col1, col2, col3) =
(SELECT col1, col2, col3 FROM
(SELECT col1, col2, col3
FROM table1 in,
table2 a,
table3 b
WHERE a.subid = in.subid
AND in.id BETWEEN min AND max
AND b.custid = a.custid
AND b.exp_date IS NULL
AND a.amount <> rc) lts
WHERE lts.id = out.id
AND lts.rc IS NOT NULL)

Member Avatar

Okay...
1. Your Update statement has NO Where clause.
2. You have a Select statement within a Select statement that is NOT needed. ie. Simplify it!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.