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 for hfx642

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.