Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Update


Message #1 by "Catalin Ignat" <cignat@s...> on Wed, 11 Dec 2002 15:16:35 +0200
I got verbose on explaining the where, my correction to your post was the
line:
SET <TABLE2>.<Column> = 1
to
set table2.column2=table1.column2

to update it using the value in table1 which I thought was what the original
question was about.

Brian Freeman
(xxx) xxx-xxxx  ext. 415
Carnegie Technologies/Bluewave Computing 
www.carnegie.com and www.bluewave-computing.com

-----Original Message-----
From: Richard Hadfield [mailto:Richard.Hadfield@t...]
Sent: Wednesday, December 11, 2002 9:45 AM
To: sql language
Subject: [sql_language] RE: Update


hence the WHERE ... 

	I thought the solution required was the syntax for joining and
updating, under the impression that people are aware of such dangers  and
the where part would be self explanatory ;-) 



-----Original Message-----
From: Brian Freeman [mailto:freeman@C...]
Sent: 11 December 2002 14:35
To: sql language
Subject: [sql_language] RE: Update


Richard was close but that update statement will put a number 1 in column
for all situations and not the value from table1.

To update column2 in table2 with the values from table1 column2 given
column1 are the same this is the statement:

UPDATE <TABLE2>
SET <TABLE2>.<Column2> = table1.column2
FROM         TABLE1 INNER JOIN
                      <TABLE2> ON <TABLE1>.<column1> = <TABLE2>.<column1>

If you want to update only certain rows you can restrict the update with a
where clause specifying table1 values or table2 values
i.e. where table1.column1>100 or where table2.column2 is null etc


Brian Freeman
(xxx) xxx-xxxx  ext. 415
Carnegie Technologies/Bluewave Computing 
www.carnegie.com and www.bluewave-computing.com

-----Original Message-----
From: Richard Hadfield [mailto:Richard.Hadfield@t...]
Sent: Wednesday, December 11, 2002 8:20 AM
To: sql language
Subject: [sql_language] RE: Update


I think this should do it


UPDATE <TABLE2>
SET <TABLE2>.<Column> = 1
FROM         TABLE1 INNER JOIN
                      <TABLE2> ON <TABLE1>.<column> = <TABLE2>.<column>
WHERE ...

-----Original Message-----
From: Catalin Ignat [mailto:cignat@s...]
Sent: 11 December 2002 13:17
To: sql language
Subject: [sql_language] Update


Hello,

Given two tables, both with same structure: two columns A and B. Same data
for column A in both tables, but in one table column B has no data - NULL
values.
My question is: how can i update in one SQL query this table which contain
empty B fields, with B fields from the second table.

Thanks,
Catalin





NOTICE AND DISCLAIMER:
This email (including attachments) is confidential.  If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents.  We cannot accept liability for any breaches of
confidence arising through use of email.  Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions.  We will not accept responsibility for any commitments
made by our employees outside the scope of our business.  We do not warrant
the accuracy or completeness of such information.







NOTICE AND DISCLAIMER:
This email (including attachments) is confidential.  If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents.  We cannot accept liability for any breaches of
confidence arising through use of email.  Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions.  We will not accept responsibility for any commitments
made by our employees outside the scope of our business.  We do not warrant
the accuracy or completeness of such information.




  Return to Index