Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> A confusion about UPDATE command

A confusion about UPDATE command

From: dn.usenet <dn.usenet_at_gmail.com>
Date: 31 Mar 2006 13:23:45 -0800
Message-ID: <1143840225.737536.301700@g10g2000cwb.googlegroups.com>

I have two tables, both with same 2 fields for primary key and total four fields.
Table-names : t11, t22
fields : mydate varchar2(16) not null, mytime varchar2(16) not null, name varchar2(16)
primary key for both tables : (mydate, mytime)

t11 has 3 entries, t22 has two entries.
update t11 t1 set t1.name = (select t2.name from t22 t2 where t2.mydate = t1.mydate

   and t2.mytime = t1.mytime)

I expect it to update 0 or 1 or 2 rows depending on how many rows of t11 satisfy the WHERE clause. But this command updates all 3 rows of t11. Why? What is the correct way of doing this type of update?

Also, if I want to add more clauses for fields of t11, should I add them within the bracket or outside of it or in both the places.

case a) update t11 t1 set t1.name = (select t2.name from t22 t2

    where t2.mydate = t1.mydate and t2.mytime = t1.mytime and t1.name =
'paul' )

case b) update t11 t1 set t1.name = (select t2.name from t22 t2

   where t2.mydate = t1.mydate and t2.mytime = t1.mytime )    where t1.name = 'paul'
case b) update t11 t1 set t1.name = (select t2.name from t22 t2

   where t2.mydate = t1.mydate and t2.mytime = t1.mytime and t1.name =
'paul' )

   where t1.name = 'paul'

Thanks in advance. Received on Fri Mar 31 2006 - 15:23:45 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US