Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search and update query

Status
Not open for further replies.

MDA

Technical User
Joined
Jan 16, 2001
Messages
243
Location
US
Hi all,

I need to compose a query that searchs for a "string" and updates one of the columns within the string.

Example:
TABLE: A
COL1, COL2, COL3, COL4, COL5

TABLE: B
COL1, COL2, COL3, COL4, COL5, COL55

In plain english I need to
UPDATE TABLE A and
SET A.COL5 = B.COL55
FROM A,B
WHERE A.COL1,A.COL2,A.COL3,A.COL4,A.COL5 = B.COL1,B.COL2,B.COL3,B.COL4,B.COL5


Any ideas how to do this in SQL?

Thanks in advance for any ideas.
Regards,
MDA
 
this should work

Code:
UPDATE TABLE A and 
 SET A.COL5 = B.COL55  
 FROM A
      JOIN B ON A.COL1 = B.COL1
                A.COL2 = B.COL2
                A.COL3 = B.COL3
                A.COL4 = B.COL4
                A.COL5 = B.COL5

"Shoot Me! Shoot Me NOW!!!"
- Daffy Duck
 
Thanks Daffy...

I just made a slight change for my test and it worked great.

--------
UPDATE A
SET A.COL4 = B.COL5
FROM A JOIN B ON A.COL1 = B.COL1 AND
A.COL2 = B.COL2 AND
A.COL3 = B.COL3 AND
A.COL4 = B.COL4 AND
A.COL5 = B.COL5


--------

Thanks again for your time.
M
 
D'OH I knew I forgot something

"Shoot Me! Shoot Me NOW!!!"
- Daffy Duck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top