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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPDaTE JOINED TABLES 1

Status
Not open for further replies.

Johnny48

Technical User
Aug 19, 2010
18
CA
Hello..

Will this work :
Code:
UPDATE POPORL 
  SET POPORL.EXPARRIVAL = 20100418 
  FROM POPORH1  POPORL 
 WHERE POPORL.PORHSEQ=POPORH1.PORHSEQ
   AND POPORH1.PONUMBER="004386"
 
I think it should. It'll probably depend on the version of PSQL you are using. Here's an example from the PSQL documentation:
Code:
CREATE table t1 (c1 integer, c2 integer)
INSERT INTO t1 VALUES (0, 10)
INSERT INTO t1 VALUES (0, 10)
INSERT INTO t1 VALUES (2, 20)
INSERT INTO t1 VALUES (2, 20)
DROP table t2
CREATE table t2 (c1 integer, c2 integer)
INSERT INTO t2 VALUES (2, 20)
INSERT INTO t2 VALUES (2, 20)
INSERT INTO t2 VALUES (3, 30)
INSERT INTO t2 VALUES (3, 30)
UPDATE t1 SET t1.c1 = 1 FROM t2 WHERE t1.c2 = t2.c2

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
Thank You Mirtheil :),
This seem to do the trick without killing the tables...:
Code:
UPDATE POPORL SET POPORL.EXPARRIVAL = 20100418
  FROM POPORH1 
WHERE POPORL.PORHSEQ=POPORH1.PORHSEQ
AND POPORH1.PONUMBER='004386'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top