954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

update table using 3 tables

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)

mamtha
Newbie Poster
7 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

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!

hfx642
Posting Pro
515 posts since Nov 2009
Reputation Points: 248
Solved Threads: 105
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You