Click to See Complete Forum and Search --> : multiple rows on update


gurupot
September 20th, 2005, 02:06 PM
Hi,

When I execute a simple SQL statement like "SELECT * FROM TAB1 WHERE PIN = '123'", I get 1 row displayed.

But when I do an update with the same condition using "UPDATE TAB1 SET BALANCE = '1000' WHERE PIN = '123'", It shows me the following output.

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)

Why is it showing 3 rows are updated. Why is it not showing these 3 rows when I do a select.

Can anyone explain me this. I am using a SQL server.

olivthill
September 20th, 2005, 03:50 PM
Maybe it is because the SELECT statement is doing an implicit "DISTINCT" selection, displaying only one line even though there are three (identical) records in the database.
After the update, can you perform again your select query to see if one or three records are displayed? If only one is shown again, this will validate my hypothesis.

gurupot
September 20th, 2005, 03:58 PM
It still shows 1 record when I do a select after an update.

How do I set the select statement not to do an implicit distinct?

olivthill
September 20th, 2005, 04:11 PM
If I remember well, you can use the "ALL" keyword, e.g. "SELECT ALL * FROM TAB1 WHERE PIN = '123'".

erickwidya
September 20th, 2005, 09:45 PM
or SELECT COUNT(*) FROM TAB1 WHERE PIN ='123'