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!

Please help me parse a string into a new table...

Status
Not open for further replies.

jmerrow

Technical User
Jan 23, 2003
2
US
I need to take the following fields...
id, string, and parse the string into a new table as follows:

Table1
id1 string1
----- -------
1234 123,456,789

into
Table 2
id2 string2
---- -------
1234 123
1234 456
1234 789

I am using DAO in Access 97. Please help! Thanks.
 
query1

SELECT table1.id1, table1.str1,left(str1, InStr(str1,",") -1) AS firstComma
, mid(str1, inStr(str1,",") + 1 , instr( instr(str1,",")+1, str1, ",") - inStr(str1,",") - 1 ) as secondComma
,mid (str1, instr( instr(str1,",")+1, str1, ",") + 1) as thirdComma
FROM table1;


INSERT INTO table2
SELECT Query1.id1, Query1.firstComma
FROM Query1;

INSERT INTO table2
SELECT Query1.id1, Query1.secondComma
FROM Query1;

INSERT INTO table2
SELECT Query1.id1, Query1.thirdComma
FROM Query1; Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top