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!

Splitting a value in one column into two separate columns

Status
Not open for further replies.

EvansEd

Programmer
Sep 30, 2002
9
US
How can I split a value that will be read-in into 1 column, and transferred to another table into two seperate columns?

Ex. Table A: Product
123456-001

data transfered into

Table B: Product_Num Product_Size
12345 001


Also, can I have the database ignore the hyphen (-) and not include it in either column in table B?

Thanks a bunch!
 
Try combining the substr and instr functions to select the portion of the string before and after the hyphen. Something like

insert into table_b (product_num, product_size)
(select substr(product, 1, instr(product, '-')-1), substr(product, instr(product, '-')+1) from table_a);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top