SQL Update Help Required 
Author Message
 SQL Update Help Required

I know it's simple. I did it before when I used Oracle for a few months
back in about 1987.

Paradox DB Tables. Delphi 2.0.

How do I update a field in one table based on the contents of another.

eg TableA has a number of fields including FieldX and FieldY

TableB has a two fields - FieldX and FieldY.

I want to update the value of FieldY in TableA with the value of FieldY
in TableB in the row where FieldX matches that in TableA

a more diagrammatic example:

Before my update query:

TableA
======

TableB
======
FieldA     FieldB
======     ======
AAA        PPP
BBB        QQQ
CCC        RRR

and after my query, what I want is

TableA
======
PK   FieldA     FieldB
==   ======     ======
01   AAA        PPP
02   BBB        QQQ
03   CCC        RRR
04   AAA        PPP

I can do it easily with QBE. I know it's easy with SQL. Please Help!
--
Tim Stannard -  Ad Hoc Computing, Addlestone, Surrey, UK



Mon, 22 Feb 1999 03:00:00 GMT
 SQL Update Help Required



Quote:
> Paradox DB Tables. Delphi 2.0.

> How do I update a field in one table based on the contents of another.

> eg TableA has a number of fields including FieldX and FieldY

> TableB has a two fields - FieldX and FieldY.

> I want to update the value of FieldY in TableA with the value of FieldY
> in TableB in the row where FieldX matches that in TableA

I have not tried this, but it may help point you in a good direction.

Try using a TUpdateSQL Component with the UPDATESQL property set as
follows:

Update TableA, TableB set TableA.FieldY = TableB.FieldY where TableA.FieldX
= TableB.FieldX

When you run this update query, it should update TableA.FieldY with the
contents of TableB.FieldY

Let me know when you get this to work.  I would like to know what
obstacles, if any, you encountered in your path.

Good Luck,

Yaron



Tue, 23 Feb 1999 03:00:00 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. sql update statement help required

2. Very Urgent - Help required on updating Metadata of SQL Server Database

3. Newbie requires Help on Updating values gathered in Text Boxes

4. Help required: Reports not updating

5. Help required with sp_OAMethod required

6. Help Required on Dynamic SQL

7. SQL Help Required

8. Help with requiring data in a SQL field

9. Sending mail alerts from SQL Server - help required

10. Help required on using JDBC with SQL Server

11. SQL Access help required.


 
Powered by phpBB® Forum Software