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!

Separating Data

Status
Not open for further replies.

tsyle

Programmer
May 16, 2005
35
US
I have a column in my database like the one below.

ID1
1092200001
1092200002
1234567890
2678100001
2678100002
2678100003
2678100004
2678100005
5112300001
5329500001
5329500002
5329500003
5329500004
5329500005

What i am trying to do is create a query where it will separate the first 4 number, next 2 numbers, and then all the rest of the numbers. For example, using these data..

5329500003
5329500004
5329500005

I want to create 3 columns. Col1 will have 5329, Col2 will have 50, and Col3 will have 0003 and 0004

So basically i just want to separate the column into 3 different columns. Is this possible to do?
 
Hi
How about:
Code:
SELECT Mid([MyColStr],1,2) AS [Col 1], Mid([MyColStr],3,2) AS [Col 2], Mid([MyColStr],1,2) AS [Col 3]
FROM MyTable;

 
SELECT Left([ID1],4) AS Col1, Mid([ID1],5,2) AS Col2, Mid([ID1],7) AS Col3
FROM yourTable

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top