Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 23rd, 2006, 01:48 AM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Update one table with other table data?

Hi,

Table 1
--------
EId FirstName LastName
---------------------------------
1 sdf df
2 sdf sdf
3 sdfd sdfsdf


Table 2
--------
EId FirstName LastName
----------------------------------
1 NULL NULL
2 NULL NULL
3 NULL NULL


How to update Table2's firstname and lastname column data using table1's data?

Ramkumar A.D.


A.D.Ramkumar
__________________
Ramkumar A D
 
Old May 25th, 2006, 02:14 PM
Registered User
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ramkumar:

Try this SQL statement:

UPDATE TBL, tblEmployees SET TBL.Firstname = TBL!Firstname, TBL.Lastname = [TBL]![Lastname]
WHERE (((TBL.Firstname)=[tblEmployees]![FirstName]) AND ((TBL.Lastname)=[tblEmployees]![LastName]));

TBL was a test table I set up in Access to make sure it worked. It does. I hope this helps. I don't know what type of RDBMS you are using but this does work in Access.

Thanks,
Jack Britton

 
Old May 26th, 2006, 12:51 AM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I am using SQL Server 2000 for this and the reply that i got is:


update table2 set firstname=table1.firstname, lastname=table1.lastname from table1,table2
where table1.eid=table2.eid


A.D.Ramkumar





Similar Threads
Thread Thread Starter Forum Replies Last Post
Update one table to another table using DTS in SQL Printmaker SQL Language 0 July 24th, 2007 07:17 AM
Update data from another table Sheikha SQL Language 1 July 11th, 2005 05:32 AM
update table with an ID Num from different table scoobie PHP How-To 12 January 25th, 2005 12:28 PM
Update parent table with the sum of child table gbrown SQL Language 2 November 9th, 2004 07:53 AM
Update SQL table with data from FoxPro system sofya SQL Server 2000 6 November 4th, 2004 06:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.