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

UPDATE one table from another

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I know there has to be a simple answer to this.

I have two tables: Table A contains line-item records for a set of orders for the current year only keyed on ORDER_NUMBER. Table B has header records for ALL orders, also keyed on ORDER_NUMBER.

Table A:
ORDER_NUMBER VARCHAR2(10)
ORDER_TYPE VARCHAR2(4)
LINE_ITEM VARCHAR2(6)
PRODUCT VARCHAR2(10)
QTY FLOAT(126)
EXT_PRICE FLOAT(126)
TOTAL_TAX FLOAT(126)

Table B:
ORDER_NUMBER VARCHAR2(10)
ORDER_TYPE VARCHAR2(4)
WAREHOUSE VARCHAR2(4)
CUST_SHIP_TO VARCHAR2(12)
TOTAL_TAX FLOAT(126)

I need to update records in Table A with the contents of the ORDER_TYPE and TOTAL_TAX fields in Table B. Remember, not every ORDER_NUMBER in B is in A; for every matching ORDER_NUMBER, there will be 1 to n records in A for every one in B.

How do I write an UPDATE to do this?

Thanks for your help!
Lee
lee.meinhardt@smna.com

 
Based on the description you provided, does this seem to do it for you?

Update TABLEA Set
ORDER_TYPE = TABLEB.ORDER_TYPE,
TOTAL_TAX = TABLEB.TOTAL_TAX

From TABLEA Inner Join TABLEB
On TABLEA.ORDER_NUMBER = TABLEB.ORDER_NUMBER

bp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top